0

I need to pass the following SOAP header into a WCF service call.

<wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
     <wsu:Timestamp wsu:Id="TS-3DCA13685AB558766615063665309446">
        <wsu:Created>2017-09-25T19:08:50.943Z</wsu:Created>
        <wsu:Expires>2017-09-25T20:48:50.943Z</wsu:Expires>
     </wsu:Timestamp>
     <wsse:UsernameToken wsu:Id="UsernameToken-3DCA13685AB558766615063665252595">
        <wsse:Username>prdIDXXXX</wsse:Username>
        <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">XXXXXX</wsse:Password>
        <wsu:Created>2017-09-25T19:08:45.259Z</wsu:Created>
     </wsse:UsernameToken>
  </wsse:Security>

The problem is, most of the solution in stackoverflow or other forums does this by creating a HttpWebRequest object.

example: calling WCF services using SOAP

However, in my case I already have a Service proxy class generated from WSDL. The proxy class has already created the service calling signature:

myResponseObject = ServiceProxy.MyServiceMethod(myRequestObject1, myRequestObject2);

How do I "inject" my soap header in the service call?

Bluemarble
  • 1,925
  • 4
  • 20
  • 35

1 Answers1

0

To create or alter the SOAP of WCF service,you need to use MessageContract as DataContract doesnt have much control over the SOAP messages. With this you can alter the SOAP header,body by passing required request and response.Refer the below link

http://csharp-video-tutorials.blogspot.in/2013/11/part-10-message-contract-in-wcf_28.html

Hameed Syed
  • 3,939
  • 2
  • 21
  • 31