SOAP HeaderElement
The optional SOAP Header element contains header information.
SOAP Header Element
The optional SOAP Header element can contain application-specific information about the SOAP message (such as authentication, payment, etc.).
If the Header element is provided, it must be the first child element of the Envelope element.
Note:All direct child elements of the Header element must be namespace qualified.
<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 above example contains a header with a "Trans" element whose value is 234, and the "mustUnderstand" attribute of this element has a value of "1".
SOAP defines three attributes in the default namespace ("http://www.w3.org/2001/12/soap-envelope").
These three attributes are: actor, mustUnderstand, and encodingStyle. These attributes defined in the SOAP header can define how a container processes the SOAP message.
mustUnderstand Attribute
SOAP's mustUnderstand attribute can be used to identify whether a header item is mandatory or optional for the receiver that processes it.
If you add "mustUnderstand="1"" to a child element of the Header element, it indicates that the receiver processing this header must acknowledge this element. If the receiver cannot acknowledge this element, it must fail when processing this header.
Syntax
Example
<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>
actor Attribute
By traveling along the message path through different endpoints, a SOAP message can propagate from a sender to a receiver. Not all parts of a SOAP message are intended for the final endpoint of the SOAP message, but on the other hand, they may be intended for one or more endpoints on the message path.
SOAP's actor attribute can be used to address a Header element to a specific endpoint.
Syntax
Example
<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:actor="http://www.w3schools.com/appml/">234
</m:Trans>
</soap:Header>
...
...
</soap:Envelope>
encodingStyle Attribute
SOAP's encodingStyle attribute is used to define the data types used in the document. This attribute can appear in any SOAP element, and it will be applied to the content of the element and all child elements of the element.
SOAP messages have no default encoding method.
Syntax
Other Extensions