Add WS Addressing SOAP header

Dec 13, 2010 at 9:23 AM

Hi,

I am using a WCF client to connect to a web service hosted on IBM WebSphere/DataPower.

I need the SOAP message to be sent in the following format:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/
 xmlns:ns="<custom namespace>"  xmlns:ver="<custom namespace>
 xmlns:a="http://www.w3.org/2005/08/addressing">
   <soapenv:Header>
      <wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
         <wsse:UsernameToken>
            <wsse:Username><!--removed--></wsse:Username>
            <wsse:Password><!--removed--></wsse:Password>
         </wsse:UsernameToken>
      </wsse:Security>
      <a:Action><!--Action URL--></a:Action>
      <a:To><!-- To URL--></a:To>
   </soapenv:Header>
   <soapenv:Body>
      <ns:crNumber>5855008405</ns:crNumber>
   </soapenv:Body>
</soapenv:Envelope>

The elements in bold need to be inserted in the SOAP header. I am using the WSDL provided by the service owner to create the service reference from Visual Studio 2010.

Is it possible to do this using WCF Extras? Any other good alternative?

 

Jan 11, 2011 at 7:46 PM

I am seeking to do the exact same thing, did you have any success implementing this? thanks

Jan 12, 2011 at 2:33 PM

 

Yes I could solve it by using the following customBinding

 

 

      <customBinding>
        <binding name="SecuritySoapWSAddressing">
          <textMessageEncoding messageVersion="Soap11WSAddressing10" writeEncoding="utf-8" />
          <security authenticationMode="UserNameOverTransport" includeTimestamp="false" />
          <httpsTransport maxBufferPoolSize="52428800" maxReceivedMessageSize="6553600" maxBufferSize="6553600" 
                          requireClientCertificate="true" />
        </binding>
      </customBinding>

and used it in the endpoint as below:
    <client>
      <endpoint address="<URL>"
        binding="customBinding" bindingConfiguration="SecuritySoapWSAddressing"
        contract="SecureMociRegnSvcRef.MOCIRegistrationService" name="MOCIRegistrationServicePort" />
    </client>


Jan 12, 2011 at 3:50 PM

thanks a lot for your reply niyazshah,

in addition to the binding/endpoint config, can you post the code you used to pass the authentication token?

thanks

Jan 12, 2011 at 5:58 PM

Please see the code below:

            client.ChannelFactory.Credentials.UserName.UserName = wsseUser;
            client.ChannelFactory.Credentials.UserName.Password = wssePwd;

where client is the proxy client for the service