I am new to both WSE and WCF and I am trying to consume a web service using WCF but all the example documentation is for VS2005 + WSE. This web service uses WS-Security 1.0. I have added a service reference through visual studio but I am at a loss on how to do the equivalent of the code below in 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);
Best Solution
After spending a day doing some experimentation I figured out how to convert this code. The key was setting up the bindings on the WCF proxy that VS2008 makes correctly.
Open App.config / Web.config and locate the system.serviceModel section. Change the security mode on the default soapbinding to be TransportWithMessageCredential. Here is what my file looked like after the change:
Change the example code above to look like this
TransportWithMessageCredential is equivalent to UsernameOverTransportAssertion policy under WSE 3.0