The optional SOAP Header element contains header information.
SOAP Header element
Optional SOAP header elements can contain application-specific information (such as authentication and payment) about soap messages ). If the Header element is provided, it must be the first child element of the envelope element.
Note: The direct sub-elements of all header elements must be qualified namespaces.
<?xml version="1.0"?><soap:Envelopexmlns:soap="http://www.w3.org/2001/12/soap-envelope"soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding"><soap:Header><m:Transxmlns:m="http://www.w3school.com.cn/transaction/"soap:mustUnderstand="1">234</m:Trans></soap:Header>......</soap:Envelope>
The preceding example contains a header with a "trans" element. Its value is 234. The value of the "mustunderstand" attribute of this element is "1 ".
In the default namespace ("http://www.w3.org/2001/12/soap-envelope"), Soap defines three attributes. These three attributes are: Actor, mustunderstand, and encodingstyle. These attributes defined in the SOAP header can define how the container processes soap messages.
Actor attributes
By passing through different endpoints along the message path, soap messages can be transmitted from a sender to a receiver. Not all parts of a SOAP message are intended to be transmitted to the end endpoint of the SOAP message. However, another aspect may be intended to be transmitted to one or more endpoints on the message path.
The actor attribute of soap can be used to address the Header element to a specific endpoint.
Syntax
soap:actor="URI"
Instance
<?xml version="1.0"?><soap:Envelopexmlns:soap="http://www.w3.org/2001/12/soap-envelope"soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding"><soap:Header><m:Transxmlns:m="http://www.w3school.com.cn/transaction/"soap:actor="http://www.w3school.com.cn/appml/">234</m:Trans></soap:Header>......</soap:Envelope>
Mustunderstand attributes
The mustunderstand attribute of soap can be used to identify whether a title item is mandatory or optional for the recipient to process it.
If you add "mustunderstand =" 1 "to a child element of the header, it indicates that the recipient processing this header must recognize this element. If the recipient cannot recognize this element, it must be invalid when processing this header.
Syntax
soap:mustUnderstand="0|1"
Instance
<?xml version="1.0"?><soap:Envelopexmlns:soap="http://www.w3.org/2001/12/soap-envelope"soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding"><soap:Header><m:Transxmlns:m="http://www.w3school.com.cn/transaction/"soap:mustUnderstand="1">234</m:Trans></soap:Header>......</soap:Envelope>
Encodingstyle attributes
The encodingstyle attribute of soap has been explained in the previous section.