SOAP Header Element
- Previous Page SOAP Envelope
- Next Page SOAP Body
可选的 SOAP Header 元素包含头部信息。
SOAP Header Element
可选的 SOAP Header 元素可包含有关 SOAP 消息的应用程序专用信息(比如认证、支付等)。如果 Header 元素被提供,则它必须是 Envelope 元素的第一个子元素。
注释:所有 Header 元素的直接子元素必须是合格的命名空间。
<?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.codew3c.com/transaction/" soap:mustUnderstand="1">234</m:Trans> </soap:Header> ... ... </soap:Envelope>
上面的例子包含了一个带有一个 "Trans" 元素的头部,它的值是 234,此元素的 "mustUnderstand" 属性的值是 "1"。
SOAP 在默认的命名空间中 ("http://www.w3.org/2001/12/soap-envelope") 定义了三个属性。这三个属性是:actor、mustUnderstand 以及 encodingStyle。这些被定义在 SOAP 头部的属性可定义容器如何对 SOAP 消息进行处理。
actor 属性
通过沿着消息路径经过不同的端点,SOAP 消息可从某个发送者传播到某个接收者。并非 SOAP 消息的所有部分均打算传送到 SOAP 消息的最终端点,不过,另一个方面,也许打算传送给消息路径上的一个或多个端点。
SOAP 的 actor 属性可用于将 Header 元素寻址到一个特定的端点。
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.codew3c.com/transaction/" soap:actor="http://www.codew3c.com/appml/"> 234 </m:Trans> </soap:Header> ... ... </soap:Envelope>
mustUnderstand Attribute
The mustUnderstand attribute of SOAP can be used to identify whether the title item is mandatory or optional for the receiver who needs to process it.
If you add "mustUnderstand="1" to a child element of the Header element, it can indicate that the receiver who processes this header must recognize this element. If this receiver cannot recognize this element, it must be invalid 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.codew3c.com/transaction/" soap:mustUnderstand="1"> 234 </m:Trans> </soap:Header> ... ... </soap:Envelope>
encodingStyle Attribute
The encodingStyle attribute of SOAP has been explained in the previous section.
- Previous Page SOAP Envelope
- Next Page SOAP Body