![](https://csdnimg.cn/release/download_crawler_static/88335379/bg5.jpg)
</m:GetPrice>
</soap:Body>
</soap:Envelope>
上面的例子请求苹果的价格。请注意,上面的 m:GetPrice 和 Item 元素是应用程序专用的
元素。它们并不是 SOAP 标准的一部分。而对应的 SOAP 响应应该类似这样:
Java 代码
<?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.jsoso.net/prices">
<m:Price>1.90</m:Price>
</m:GetPriceResponse>
</soap:Body>
</soap:Envelope>
<?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.jsoso.net/prices">
<m:Price>1.90</m:Price>
</m:GetPriceResponse>
</soap:Body>
</soap:Envelope>
SOAP Fault 元素
Fault 元素表示 SOAP 的错误消息。它必须是 Body 元素的子元素,且在一条 SOAP 消息
中,Fault 元素只能出现一次。Fault 元素拥有下列子元素:
常用的 SOAP Fault Codes
HTTP 协议中的 SOAP 实例
下面的例子中,一个 GetStockPrice 请求被发送到了服务器。此请求有一个 StockName 参
数,而在响应中则会返回一个 Price 参数。此功能的命名空间被定义在此地址中:
"http://www.jsoso.net/stock"
SOAP 请求:(注意 HTTP 的 Head 属性)
Java 代码
POST /InStock HTTP/1.1
Host: www.jsoso.net