第三十九章 添加和使用 WS-Addressing 标头元素 - 响应消息中的默认 WS-Addressing 标头元素
响应消息中的默认 WS-Addressing
标头元素
如果按本节前面所述启用 WS-Addressing
,并且请求消息包含 WS-Addressing
标头元素,则 Web
服务将在其响应消息中包含以下 WS-Addressing
标头元素:
-
To: anonymous
-
Action: SoapAction_"Response"
-
MessageID: unique uuid
-
RelatesTo: MessageID of request
<?xml version="1.0" encoding="UTF-8" ?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV='https://schemas.xmlsoap.org/soap/envelope/'
xmlns:xsi='https://www.w3.org/2001/XMLSchema-instance'
xmlns:s='https://www.w3.org/2001/XMLSchema'
xmlns:wsa='https://www.w3.org/2005/08/addressing'>
<SOAP-ENV:Header>
<wsa:Action>https://www.myapp.org/GSOAP.DivideAddressingWS.DivideResponse</wsa:Action>
<wsa:MessageID>urn:uuid:577B5D65-D7E3-4EF7-9BF1-E8422F5CD739</wsa:MessageID>
<wsa:RelatesTo>urn:uuid:91576FE2-4533-43CB-BFA1-51D2B631453A</wsa:RelatesTo>
<wsa:To>https://www.w3.org/2005/08/addressing/anonymous</wsa:To>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<DivideResponse xmlns="https://www.myapp.org">
<DivideResult>.1428571428571428571</DivideResult>
</DivideResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
手动添加 WS-Addressing
标头元素
可以不使用默认的 WS-Addressing
标头元素,而是手动创建并添加自己的元素。具体操作如下:
- 创建
%SOAP.Addressing.Properties
的实例并根据需要指定其属性。有关详细信息,请参阅类参考。 - 将
Web
服务或客户端的AddressingOut
属性设置为的%SOAP.Addressing.Properties
的此实例。
注意:如果设置了 AddressingOut
属性,则 Web
服务或 Web
客户端将使用此属性中的 WS-Addressing
标头元素,而不是附加策略中指定的任何 WS-Addressing
元素。
处理 WS-Addressing
标头元素
当 Web 服务或客户端收到包含 WS-Addressing
标头元素的消息时,服务或客户端的 AddressingIn
属性将更新为 %SOAP.Addressing.Properties
的实例。然后 Web
服务或客户端可以检查其 AddressingIn
属性的详细信息。
网友评论