Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to sign a SOAP request with WCF

I have an 3rd party SOAP web service. I need to make a call to one of its methods. The request needs to be signed. How can I sign the request?

like image 799
Mr Bell Avatar asked Feb 18 '10 21:02

Mr Bell


2 Answers

I assume by signing you mean that you sign the message using a certificate that is installed on the client side.

Doing this is relatively easy in WCF. Assuming you are using the wsHttpBinding in the security element you have to set the mode to SecurityMode.Message. You also have to set the clientCredentialType of the message element to MessageCredentialType.Certificate.

Then, you would have to set up a endpoint behavior and configure the clientCertificate element (which is a child of the clientCredentials element) to indicate where the client certificate is stored.

Even if you aren't using the wsHttpBinding, the configuration is pretty much the same for most of the other bindings when you want to use a client certificate to provide message-level security.

If you are making the call over HTTPS, then note that you will have to set the mode attribute on the security element to Mode.TransportWithMessageCredential.

like image 64
casperOne Avatar answered Sep 30 '22 00:09

casperOne


The following is a question that was asked about using WCF to use the Amazon SOAP service which requires signing. I think the answer gives a great example, which might help with your situation.

How to sign an Amazon web service request in .NET with SOAP and without WSE

Edit: There was evidently some confusion about the link to this other StackOverflow question. I would like to point out the highest voted chosen answer. It is most definitely a WCF solution. You will notice the class SigningMessageInspector which inherits from IClientMessageInspector (a WCF interface). I think this section might help you.

like image 28
Tim C Avatar answered Sep 30 '22 01:09

Tim C