SOAP Header element
Optional SOAP Header
element contains header information.
SOAP Header element
The optional SOAP Header element can contain application-specific information about SOAP messages (such as authentication, payments, and so on).
If Header
element is provided, it must be a Envelope
the first child of the element.
Note: all Header
the immediate child element of the element must be a qualified namespace.
<?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 above example contains a header with a “Trans” element with a value of 234. the value of the “mustUnderstand” attribute of this element is “1”.
SOAP is in the default namespace (”http://www.w3.org/2001/12/soap-envelope”) defines three attributes.”
These three attributes are: actor
、 mustUnderstand
and encodingStyle
. These properties, defined in the SOAP header, define howthe container handles SOAP messages.
MustUnderstand attribute
The mustUnderstand property of SOAP can be used to identify whether the title 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 the header must recognize the element. If the recipient cannot recognize the element, it must fail to process the header.
Grammar
soap:mustUnderstand="0|1"
Example
<?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>
Actor attribute
SOAP messages can be propagated from a sender to a receiver by passing through different endpoints along the message path. Not all parts of the SOAP message are intended to be delivered to the final endpoint of the SOAP message, but on the other hand, it may be intended to be delivered to one ormore endpoints on the message path.
SOAP’s actor
property can be used to set the Header
element is addressed to a specific endpoint.
Grammar
soap:actor="*URI*"
Example
<?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:actor="http://www.w3schools.com/appml/">234
</m:Trans>
</soap:Header>
...
...
</soap:Envelope>
EncodingStyle attribute
SOAP’s encodingStyle
property is used to define the data type used in the document. This attribute can appear in any SOAP element and is applied to the contents of the element and to all child elements of the element.
There is no default encoding for SOAP messages.
Grammar
soap:encodingStyle="*URI*"