SOAP 实例

一个 SOAP 实例

在下面的例子中,一个 GetStockPrice 请求被发送到了服务器。此请求有一个 StockName 参数,而在响应中则会返回一个 Price 参数。此功能的命名空间被定义在此地址中: "http://www.example.org/stock"

SOAP 请求:

  1. POST /InStock HTTP/1.1
  2. Host: www.example.org
  3. Content-Type: application/soap+xml; charset=utf-8
  4. Content-Length: nnn
  5.  
  6. <?xml version="1.0"?>
  7. <soap:Envelope
  8. xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
  9. soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
  10.  
  11. <soap:Body xmlns:m="http://www.example.org/stock">
  12. <m:GetStockPrice>
  13. <m:StockName>IBM</m:StockName>
  14. </m:GetStockPrice>
  15. </soap:Body>
  16.  
  17. </soap:Envelope>

SOAP 响应:

  1. HTTP/1.1 200 OK
  2. Content-Type: application/soap+xml; charset=utf-8
  3. Content-Length: nnn
  4.  
  5. <?xml version="1.0"?>
  6. <soap:Envelope
  7. xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
  8. soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
  9.  
  10. <soap:Body xmlns:m="http://www.example.org/stock">
  11. <m:GetStockPriceResponse>
  12. <m:Price>34.5</m:Price>
  13. </m:GetStockPriceResponse>
  14. </soap:Body>
  15.  
  16. </soap:Envelope>