views:

217

answers:

1

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 provided 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

+3  A: 

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";
Drew Marsh
WCF supports just about every imaginable WS-* standard :-)
marc_s
@marc_s And if it doesn't, you can add it on yourself. I looooves me some WCF. :)
Drew Marsh