Latest web development tutorials

SOAP Header element

The optional SOAP Header element contains header information.


SOAP Header element

The optional SOAP Header element contains application-specific information about the SOAP message (such as authentication, payment, etc.).

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, its value is 234, the value "mustUnderstand" attribute of this element is "1."

SOAP in the default namespace ( "http://www.w3.org/2001/12/soap-envelope") defines three attributes.

The three properties are: actor, mustUnderstand and encodingStyle. These are defined in the SOAP header attribute defines how a recipient should process the SOAP message.


mustUnderstand attribute

The SOAP mustUnderstand attribute can be used to identify the heading for the recipient to be treated it is mandatory or optional.

If when you add "mustUnderstand =" 1 ", it indicates that the receiver processing the Header must recognize the element. If the receiver does not recognize this element in the process this header to a child element of the Header element It must fail.

grammar

soap:mustUnderstand="0|1"

Examples

<?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

Pass along the message path through different endpoints, SOAP messages can be transmitted from a sender to a receiver. Not all parts of the SOAP message intended for the ultimate endpoint of the SOAP message, however, another aspect, perhaps intended to convey a message to the path on one or more endpoints.

The SOAP actor attribute can be used to address the Header element to a particular endpoint.

grammar

soap:actor="URI"

Examples

<?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 property

SOAP encodingStyle attribute for the data type definitions used in the document. This attribute may appear on any SOAP element, and it will apply to all sub-elements and element content of the element.

SOAP message is no default encoding.

grammar

soap:encodingStyle="URI"