Last post Nov 19, 2013 03:33 AM by Amy Peng - MSFT
Nov 11, 2013 02:55 AM|srabol|LINK
I'm trying to communicate with a SAP web service.
I have received the WSDL, created the proxy classes using the WSDL tool.
For some reason this web service requires a 'special' tag in the SOAP header
<msgID:MessageId xmlns="..."><some unique id></msgId:MessageId>
Now... Adding a tag in the header can be done using a SoapHeader class and some code to initialize the header before the call that invoke the SAP service.
here is my SoapHeader class:
[System.Xml.Serialization.XmlRoot(Namespace = "http://www.sap.com/webas/640/soap/features/messageId/")]
public class MyMessageId : SoapHeader
public string value;
I have a public var in my proxy class:
public MyMessageId headerMessageId;
and in my call to the service I have this:
headerMessageId = new MyMessageId();
headerMessageId.value = Guid.NewGuid().ToString();
And the resut is this:
There are two things 'wrong'
1) why do I get a <MyMesageId> and a Child <Value>, I need only one level
2) how can I name the tag <msgID:MessageId> - Tricky part here is the ':' (Colon) in the tag name
for 2) - I know that there is the - [System.Xml.Serialization.XmlRoot(Namespace = "http://www.sap.com/webas/640/soap/features/messageId/",ElementName="msgId:MessageId")]
but this is the result:
notice the _x003>_ shold have been ':' and I still get the child <value> element
How do I solve these 2 issues ?
Thanks in advance.
Nov 19, 2013 03:33 AM|Amy Peng - MSFT|LINK
If we you want to add a special tag in the SOAP headers in your messages, I think your best bet would really be to use message contracts. That's really the sole purpose of message contracts: defining the explicit SOAP message layout, including custom headers.
Please try to check some articles and blog posts on the topic:
Add custom headers to a WCF channel