”;
The optional Header element offers a flexible framework for specifying additional application-level requirements. For example, the Header element can be used to specify a digital signature for password-protected services. Likewise, it can be used to specify an account number for pay-per-use SOAP services.
Points to Note
-
It is an optional part of a SOAP message.
-
Header elements can occur multiple times.
-
Headers are intended to add new features and functionality.
-
The SOAP header contains header entries defined in a namespace.
-
The header is encoded as the first immediate child element of the SOAP envelope.
-
When multiple headers are defined, all immediate child elements of the SOAP header are interpreted as SOAP header blocks.
SOAP Header Attributes
A SOAP Header can have the following two attributes −
Actor attribute
The SOAP protocol defines a message path as a list of SOAP service nodes. Each of these intermediate nodes can perform some processing and then forward the message to the next node in the chain. By setting the Actor attribute, the client can specify the recipient of the SOAP header.
MustUnderstand attribute
It indicates whether a Header element is optional or mandatory. If set to true, the recipient must understand and process the Header attribute according to its defined semantics, or return a fault.
The following example shows how to use a Header in a SOAP message.
<?xml version = "1.0"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV = " http://www.w3.org/2001/12/soap-envelope" SOAP-ENV:encodingStyle = " http://www.w3.org/2001/12/soap-encoding"> <SOAP-ENV:Header> <t:Transaction xmlns:t = "http://www.tutorialspoint.com/transaction/" SOAP-ENV:mustUnderstand = "true">5 </t:Transaction> </SOAP-ENV:Header> ... ... </SOAP-ENV:Envelope>
”;