Error in WCF client consuming Axis 2 web service with WS-Security UsernameToken PasswordDigest authentication scheme

后端 未结 3 837
死守一世寂寞
死守一世寂寞 2020-11-30 07:59

I have a WCF client connecting to a Java based Axis2 web service (outside my control). It is about to have WS-Security applied to it, and I need to fix the .NET client. Howe

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-30 08:38

    I had a similar problem recently and gave up searching for a non-WSE solution. After a couple days of pulling my hair out I ended downloading the WSE 3.0 SDK, generating a proxy class using WseWsdl3.exe, and creating a new policy for the UsernameToken. I was up and running in 15min. The following is currently working for me.

    RemoteService service = new RemoteService();  //generated class
    
    UsernameToken token = new UsernameToken(username, password, PasswordOption.SendPlainText);
    Policy policy = new Policy();
    policy.Assertions.Add(new UsernameOverTransportAssertion());
    
    service.SetClientCredential(token);
    service.SetPolicy(policy);
    
    var result = service.MethodCall();
    

提交回复
热议问题