Soap 简明教程

SOAP - Message Structure

一条 SOAP 消息是一个普通的 XML 文档,包含以下元素:

A SOAP message is an ordinary XML document containing the following elements −

  1. Envelope − Defines the start and the end of the message. It is a mandatory element.

  2. Header − Contains any optional attributes of the message used in processing the message, either at an intermediary point or at the ultimate end-point. It is an optional element.

  3. Body − Contains the XML data comprising the message being sent. It is a mandatory element.

  4. Fault − An optional Fault element that provides information about errors that occur while processing the message.

所有这些元素都在 SOAP 封装的默认名称空间 http://www.w3.org/2001/12/soap-envelope 和 SOAP 编码和数据类型的默认名称空间 http://www.w3.org/2001/12/soap-encoding 中声明

All these elements are declared in the default namespace for the SOAP envelope − http://www.w3.org/2001/12/soap-envelope and the default namespace for SOAP encoding and data types is − http://www.w3.org/2001/12/soap-encoding

NOTE − 所有这些规范都可能更改。因此,请持续更新 W3 网站上提供的最新规范。

NOTE − All these specifications are subject to change. So keep updating yourself with the latest specifications available on the W3 website.

SOAP Message Structure

以下框图描述了 SOAP 消息的一般结构 -

The following block depicts the general structure of 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>
      ...
      ...
   </SOAP-ENV:Header>
   <SOAP-ENV:Body>
      ...
      ...
      <SOAP-ENV:Fault>
         ...
         ...
      </SOAP-ENV:Fault>
      ...
   </SOAP-ENV:Body>
</SOAP_ENV:Envelope>