2

The enterprise 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 response. 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>
KANAGAL RAJ
  • 33
  • 1
  • 6

2 Answers2

2

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.

Yaron Naveh
  • 23,560
  • 32
  • 103
  • 158
  • Naveh, Thanks for your response. After changing the binding to custom binding with message version "Soap12WSAddressing10", I am able to test and get the right soap xml in WCF Test Client application provided by MSFT. But I have issues with accessing the web service hosted in IIS from my application. I get the error 400 as server not found. – KANAGAL RAJ Jun 23 '13 at 16:39
  • this is probably a different problem. I suggest you open a new question so it gets the right attention. Try to access the WSDL file in a browser to see if at least that works. If not there might be an iis issue, try to upload a dummy asp.net pp to see if it works. – Yaron Naveh Jun 23 '13 at 16:48
  • Thanks, I am able to browse the WSDL file from IIS. I will re-check that and raise question if I need any help. – KANAGAL RAJ Jun 23 '13 at 17:00
  • sure. would appreciate if you can mark this answer as correct. – Yaron Naveh Jun 23 '13 at 18:02
0

This is intended to do just that, at least for the request:

OperationContext.Current.RequestContext.RequestMessage.Headers.MessageId

Arsen Zahray
  • 24,367
  • 48
  • 131
  • 224