YouTip LogoYouTip

Soap Header

SOAP Header Element

SOAP Header Element

The optional SOAP Header element contains header information.

SOAP Header Element

The optional SOAP Header element can contain application-specific information related to 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 children elements of Header elements must be qualified names.

<?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 includes 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 define how the container processes the SOAP message.

mustUnderstand Attribute

The mustUnderstand attribute of SOAP is used to identify whether a header item is mandatory or optional for the receiver that needs to process it.

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

Syntax

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

As SOAP messages travel along different endpoints on the message path, they can propagate from one sender to one receiver. Not all parts of the SOAP message may be intended for the final endpoint of the SOAP message, but on the other hand, perhaps intended for 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_"

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

The encodingStyle attribute of SOAP is used to define the data types used in the document. This attribute can appear in any SOAP element and will be applied to the content of the element and all its sub-elements.

SOAP messages do not have a default encoding method.

Syntax

soap:encodingStyle="_URI_"
← Soap BodySoap Envelope β†’