SOAP Web 服务:理解 Envelope、Header、Body 与 Fault
SOAP 是基于 XML 的消息框架,用于通过不同传输协议交换结构化消息。本文以 W3C SOAP 1.2 为准,说明 Envelope、Header、Body、Fault,并将它们与 HTTP 绑定区分开。SOAP 规定消息结构,但不规定所有应用操作、安全和可靠性策略。
SOAP 是基于 XML 的消息框架,用于通过不同传输协议交换结构化消息。本文以 W3C SOAP 1.2 为准,说明 Envelope、Header、Body、Fault,并将它们与 HTTP 绑定区分开。SOAP 规定消息结构,但不规定所有应用操作、安全和可靠性策略。
SOAP 1.2 消息结构
SOAP 消息恰有一个 Envelope 根元素。可选 Header 携带供消息路径节点处理的扩展元数据;Body 承载最终接收方处理的内容。中间 SOAP 节点可以处理发给自己的头部并转发消息。下面是虚构的结构示例;GetOrder 和 correlationId 的含义应由服务契约定义。
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ex="urn:example:orders">
<env:Header><ex:correlationId>req-7</ex:correlationId></env:Header>
<env:Body><ex:GetOrder><ex:orderId>42</ex:orderId></ex:GetOrder></env:Body>
</env:Envelope>mustUnderstand 要求什么?
发给某节点且标记为 mustUnderstand="true"