5
我是WSE和WCF的新手,我試圖使用WCF使用Web服務,但所有示例文檔都是針對VS2005 + WSE。此Web服務使用WS-Security 1.0。我已經添加了通過Visual Studio的服務引用,但我就如何在WCF做下面的代碼相當於損失:將WSE示例代碼轉換爲WCF
// 1. Initialize the web service proxy
PartnerAPIWse integrationFramework = new PartnerAPIWse();
// 2. Set the username/password. This is using the Username token of WS-Security 1.0
UsernameTokenProvider utp = new UsernameTokenProvider("username", "password");
integrationFramework.SetClientCredential<UsernameToken>(utp.GetToken());
// 3. Declare the policy
Policy policy = new Policy(new UsernameOverTransportAssertion());
integrationFramework.SetPolicy(policy);
UsernameOverTransportAssertion政策供將來參考:WSE已過時。所有新的Web服務開發都應該使用WCF完成,並且WSE代碼應儘快退役。 – 2009-09-01 02:33:36