Latest web development tutorials

SOAP Body 元素

強制使用的SOAP Body 元素包含實際的SOAP 消息。


SOAP Body 元素

必需的SOAP Body 元素可包含打算傳送到消息最終端點的實際SOAP 消息。

SOAP Body 元素的直接子元素可以是合格的命名空間。

實例

<?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:Body>
<m:GetPrice xmlns:m="http://www.w3schools.com/prices">
<m:Item>Apples</m:Item>
</m:GetPrice>
</soap:Body>

</soap:Envelope>

上面的例子請求蘋果的價格。 請注意,上面的m:GetPrice 和Item 元素是應用程序專用的元素。 它們並不是SOAP 標準的一部分。

而一個SOAP 響應應該類似這樣:

<?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:Body>
<m:GetPriceResponse xmlns:m="http://www.w3schools.com/prices">
<m:Price>1.90</m:Price>
</m:GetPriceResponse>
</soap:Body>

</soap:Envelope>