Add special tag to the SOAP header RRS feed

  • Question

  • User-591144721 posted


    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:

        <MyMessageId xmlns="http://www.sap.com/webas/640/soap/features/messageId/">

    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:

      <msgId_x003A_MessageId xmlns="http://www.sap.com/webas/640/soap/features/messageId/">

    notice the _x003>_ shold have been ':' and I still get the child <value> element

    How do I solve these 2 issues ?

    Thanks in advance.

    Kind regards


    Monday, November 11, 2013 2:55 AM