SOAP Header element
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 The example contains a header with a "Trans" element whose value is 234 and whose "mustUnderstand" attribute has a value of "1".
SOAP defines three properties in the default namespace ("http://www.w3.org/2001/12/soap-envelope").
The three attributes are: actor, mustUnderstand and encodingStyle. These properties, defined in the SOAP header, define how the container handles the SOAP message.
mustUnderstand Property
SOAP's mustUnderstand property can be used to identify whether a header item is mandatory or optional for the recipient to process it.
If you add "mustUnderstand="1" to a child element of the Header element, it indicates that the recipient processing this header must recognize this element. If this recipient cannot recognize this element, then Must be invalid when processing this header
Syntax
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 properties
SOAP messages can be propagated from a sender to a receiver by passing through different endpoints along the message path. Not all parts of a SOAP message are intended to be delivered to the final endpoint of the SOAP message, but, alternatively, perhaps to one or more endpoints along 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 type used in the document. This attribute can appear on any SOAP element and will be applied to the element's content and all of its child elements.
There is no default encoding for SOAP messages.