开发者

.NET WCF calling .asmx with WS-Security

Can a .NET WCF Client program call an existing (vendor supplied) .asmx web service that uses WS-Security for logon?

In our case, the vendor has provid开发者_开发技巧ed an .asmx web service with WS-Security. We are going to try to use SOAPUI and WCFTestHarness or WCFTestClient to access it first. Would rather use WCF if possible.

Thanks,

Neal Walters


Yes, absolutely. WCF has great support for WS-Security. What kind of tokens are expected by the service for authentication?

Assuming it's just username/password, you would simply configure your binding to use TransportWithMessageCredential security where the client credential type is UserName (note: you must use the HTTPS to do this). First, define a binding like so:

<basicHttpBinding>
    <binding name=“MyBinding”>
        <security mode=“TransportWithMessageCredential”>
            <transport clientCredentialType=“None” />
            <message clientCredentialType=“UserName” />
        </security>
    </binding>
</basicHttpBinding>

Then configure your endpoint to use this binding:

<endpoint address="https://somewhere.com/TargetService.asmx" binding="basicHttpBinding" bindingConfiguration="MyBinding" />

Then at runtime, assuming you're using a generated proxy (i.e. ClientBase) you simply set the client credentials like so:

TargetServiceClient client = new TargetServiceClient();
client.Credentials.UserName.UserName = "myusername";
client.Credentials.UserName.Password = "mypassword";
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜