Page 2 of 2 FirstFirst 12
Results 11 to 15 of 15

Thread: How to add XML elements to the SOAP Header?

  1. #11

    Default

    he optional SOAP Header element contains application-specific information (like authentication, payment, etc) about the SOAP message.

    If the Header element is present, it must be the first child element of the Envelope element.

    Note: All immediate child elements of the Header element must be namespace-qualified.

    <?xml version="1.0"?>
    <soap:Envelope
    xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
    soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">

    <soap:Header>
    <m:Trans xmlns:m="http://www.w3schools.com/transaction/"
    soap:mustUnderstand="1">234
    </m:Trans>
    </soap:Header>
    ...
    ...
    </soap:Envelope>
    The example above contains a header with a "Trans" element, a "mustUnderstand" attribute with a value of 1, and a value of 234.

    SOAP defines three attributes in the default namespace ("http://www.w3.org/2001/12/soap-envelope"). These attributes are: mustUnderstand, actor, and encodingStyle.

    The attributes defined in the SOAP Header defines how a recipient should process the SOAP message.




    Overseas consultants in India
    Last edited by david beckman; Aug 8th, 2011 at 02:43 AM.

  2. #12

    Post

    Quote Originally Posted by mohareddy View Post
    Hi Patb ,

    Following may be helpful to achieve your target :
    <code>

    SOAPEnvelope soapEnvelope = ((SaajSoapMessage) webServiceMessage)
    .getSaajMessage().getSOAPPart()
    .getEnvelope();

    SaajSoapMessage soapMessage = (SaajSoapMessage)webServiceMessage;
    SOAPHeaderElement soapHeaderElement = soapMessage.getSaajMessage().getSOAPHeader().addHe aderElement(soapEnvelope.createName("Authorization "));
    soapHeaderElement.addAttribute(soapEnvelope.create Name("xmlns"), "");
    soapHeaderElement.addChildElement(soapEnvelope.cre ateName("Token"));


    </code>

    Cheers
    Mohan
    Hello Mohan bro..,

    thanks a lot! That was really helpful Keep it Up!!

  3. #13
    Join Date
    Aug 2011
    Posts
    1

    Default

    The optional SOAP Header element contains application-specific information (like authentication, payment, etc) about the SOAP message.
    If the Header element is present, it must be the first child element of the Envelope element.
    All immediate child elements of the Header element must be namespace-qualified.
    <?xml version="1.0"?>
    <soap:Envelope
    xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
    soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">

    <soap:Header>
    <m:Trans xmlns:m="http://www.w3schools.com/transaction/"
    soap:mustUnderstand="1">234
    </m:Trans>
    </soap:Header>
    ...
    ...
    </soap:Envelope>
    The example above contains a header with a "Trans" element, a "mustUnderstand" attribute with a value of 1, and a value of 234.
    SOAP defines three attributes in the default namespace ("http://www.w3.org/2001/12/soap-envelope"). These attributes are: mustUnderstand, actor, and encoding Style.
    __________________________________
    Web Design Web design refers to the screen layout used in a site.

  4. #14
    Join Date
    Aug 2011
    Posts
    1

    Default

    wow such a nice and good thread being continue here,,as well as also you are providing good info,,and i will must say its just due to yours all the efforts and hard work which can be seen here..good work,,good luck..
    ___________
    Web Design refers to the screen layout used in a site.
    Web Design refers to the screen layout used in a site.

  5. #15
    Join Date
    Aug 2011
    Posts
    3

    Default

    Quote Originally Posted by mohareddy View Post
    Following resource could serve as a starting point
    http://ww.w3schools.com/soap/soap_header.asp



    Happy Learning

    Cheers
    Mohan
    Thanks for the link!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •