none
How set/add soap headers in WCF services RRS feed

  • Question

  • The enteprise mobile device management protocol shows the below soap xml in HTTP POST Request. How can I define my web service to soap headers to include Action , MessageID, ReplyTo and To in request and respond.  I have tried defining the MessageHeader in MessageCOntract, but this results in custom namespace prefixes. I could not find a better documentation links for this. How to set the these headers in client side and web service side?

    <?xml version="1.0"?>
    <s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing"> <s:Header> 
    <a:Action s:mustUnderstand="1"> http://schemas.microsoft.com/windows/management/2012/01/enrollment/IDiscoveryService/Discover 
    </a:Action> 
    <a:MessageID>
    urn:uuid: 748132ec-a575-4329-b01b-6171a9cf8478
    </a:MessageID> 
    <a:ReplyTo> <a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
    </a:ReplyTo> 
    <a:To s:mustUnderstand="1"> https://ENROLLTEST.CONTOSO.COM/EnrollmentServer/Discovery.svc </a:To> 
    </s:Header> 
    <s:Body> 
    <Discover
    xmlns="http://schemas.microsoft.com/windows/management/2012/01/enrollment/"> 
    <request xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> 
    <RequestVersion>1.0</RequestVersion> 
    </request> 
    </Discover> 
    </s:Body> 
    </s:Envelope>


    K Raj


    • Edited by Kanagal_Raj Saturday, June 22, 2013 10:29 AM Edited title to reflect WCF
    Saturday, June 22, 2013 10:22 AM

Answers

  • Use a custom binding such that these headers are included in the request and accepted by the server:

      <binding name="NewBinding0">
        <textMessageEncoding messageVersion="Soap12WSAddressing10" />
        <httpTransport />
      </binding>

    In general there is no reason to include these headers in the response, this is not mandatory by ws-addressing. If you need then push them to the message using a message inspector.


    K Raj

    • Marked as answer by Kanagal_Raj Sunday, June 23, 2013 4:04 PM
    Sunday, June 23, 2013 4:04 PM

All replies

  • Use a custom binding such that these headers are included in the request and accepted by the server:

      <binding name="NewBinding0">
        <textMessageEncoding messageVersion="Soap12WSAddressing10" />
        <httpTransport />
      </binding>

    In general there is no reason to include these headers in the response, this is not mandatory by ws-addressing. If you need then push them to the message using a message inspector.


    K Raj

    • Marked as answer by Kanagal_Raj Sunday, June 23, 2013 4:04 PM
    Sunday, June 23, 2013 4:04 PM
  • Hi,

    Thank you for sharing your solutions and experience here. It will be very beneficial for other community members who have similar questions.

    Best Regards.


    Haixia
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, June 24, 2013 2:37 AM
    Moderator