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