The header and headerfault elements allow headers to be defined that are transmitted inside the Header element of the SOAP Envelope. It is not necessary to exhaustively list all headers that appear in the SOAP Envelope using header. For example, extensions to WSDL may imply specific headers should be added to the actual payload and it is not required to list those headers here.
Table 1–9 The SOAP Header Element Attributes
Property |
Description |
Required or Optional |
Example |
message |
Indicates WSDL message that will be used in binding to the header element. |
Required |
part1 |
part |
Indicates the parts from the WSDL message that will be included in the header element. |
Required |
part1 |
use |
Indicates how message parts will be encoded in the SOAP header. |
Required |
literal |
encodingStyle |
Indicates a particular encoding style to use. |
Optional |
http://someencodingstyle |
namespace |
Indicates the namespace of the wrapper element for RPC style messages. |
Optional |
urn:someNamespace |
Table 1–10 The SOAP Headerfault Element Attributes
Property |
Description |
Required or Optional |
Example |
name |
Indicates WSDL message that will be used in binding to the headerfault element. |
Required |
part1 |
part |
Indicates the parts from the WSDL message that will be included in the headerfault element. |
Required |
part1 |
use |
Indicates how message parts will be encoded in the SOAP headerfault. |
Required |
literal |
encodingStyle |
Indicates a particular encoding style to use. |
Optional |
http://someencodingstyle |
namespace |
Indicates the namespace of the wrapper element for RPC style messages. |
Optional |
urn:someNamespace |
The following example illustrates the SOAP header and headerfault elements:
<definitions .... > <binding .... > <operation .... > <input> <soap:header message="qname" part="nmtoken" use="literal|encoded" encodingStyle="uri-list"? namespace="uri"?>* <soap:headerfault message="qname" part="nmtoken" use="literal|encoded" encodingStyle="uri-list"? namespace="uri"?/>* <soap:header> </input> <output> <soap:header message="qname" part="nmtoken" use="literal|encoded" encodingStyle="uri-list"? namespace="uri"?>* <soap:headerfault message="qname" part="nmtoken" use="literal|encoded" encodingStyle="uri-list"? namespace="uri"?/>* <soap:header> </output> </operation> </binding> </definitions> |
The use, encodingStyle and namespace attributes are all used in the same way as with Body, only style="document" is assumed since headers do not contain parameters.
Together, the message attribute (of type QName) and the part attribute (of type nmtoken) reference the message part that defines the header type.
The optional headerfault elements which appear inside the header and have the same syntax as the header, allow specification of the header types used to transmit error information pertaining to the header, and defined by the header. The SOAP specification states that errors pertaining to headers must be returned in the headers. This mechanism allows specification of the format of such headers.