Adding SOAP:HEADER username and password with WSE 3.0

前端 未结 2 1206
既然无缘
既然无缘 2021-02-03 13:03

I have successfully created a WS client that works correctly when NOT using authentication.

However, the server (WebSphere) now requires adding a ws-security username to

2条回答
  •  臣服心动
    2021-02-03 13:40

    Make sure your proxy class inherits from Microsoft.Web.Services3.WebServicesClientProtocol.

    You can do this either by changing the proxy class itself, or by generating it via the command line using wsewsdl3.exe with the /type:webClient switch.

    You can then pass the credentials like this:

    using Microsoft.Web.Services3;
    using Microsoft.Web.Services3.Security.Tokens;
    using Microsoft.Web.Services3.Security;
    .
    .
    .
    WS.FooResultHttpService ws = new WS.FooResultHttpService();
    ws.RequestSoapContext.Security.Tokens.Add(new UsernameToken("blah", "blah", PasswordOption.SendPlainText));
    

    This is what I've done in the past to get WSE3.0 going in Studio 2008. Hope that helps.

提交回复
热议问题