locked
Add special tag to the SOAP header RRS feed

  • Question

  • User-591144721 posted

    Hi

    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:

    <soap:Header>
        <MyMessageId xmlns="http://www.sap.com/webas/640/soap/features/messageId/">
            <value>2f3bb672-4290-42ab-a89d-52099db8ff84</value>
        </MyMessageId>
    </soap:Header>

    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:

    <soap:Header>
      <msgId_x003A_MessageId xmlns="http://www.sap.com/webas/640/soap/features/messageId/">
        <value>99471c04-65c7-4829-8650-5c284f47b2a1</value>
      </msgId_x003A_MessageId>
    </soap:Header>

    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

    Steen





    Monday, November 11, 2013 2:55 AM

Answers