Contoh SOAP
Sebuah contoh SOAP
Dalam contoh berikut, permintaan GetStockPrice dihantar ke pelayan. Permintaan ini mempunyai parameter StockName dan parameter Harga dikembalikan dalam respons. Ruang nama untuk ciri ini ditakrifkan di alamat ini: "http://www.example.org/stock"
Permintaan SOAP:
POST /InStock HTTP/1.1
Hos: www.example.org
Content-Type: application/soap+xml; charset=utf-8
Content-Length: nnn
<?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 xmlns:m="http://www.example.org/stock">
<m:GetStockPrice>
<m:StockName>IBM</m:StockName>
</m:GetStockPrice>
</soap:Body>
</soap:Sampul>
Hos: www.example.org
Content-Type: application/soap+xml; charset=utf-8
Content-Length: nnn
<?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 xmlns:m="http://www.example.org/stock">
<m:GetStockPrice>
<m:StockName>IBM</m:StockName>
</m:GetStockPrice>
</soap:Body>
</soap:Sampul>
Respons SOAP:
HTTP/1.1 200 OK
Kandungan -Jenis: aplikasi/sabun+xml; charset=utf-8
Panjang Kandungan: nnn
<?xml version="1.0"?>
<sabun:Sampul
xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding" >
<soap:Body xmlns:m="http://www.example.org/stock">
, <m:GetStockPriceResponse>
<m:Harga>34.5</m:Harga>
, </m:GetStockPriceResponse>
</soap:Body>
</soap:Sampul>
Kandungan -Jenis: aplikasi/sabun+xml; charset=utf-8
Panjang Kandungan: nnn
<?xml version="1.0"?>
<sabun:Sampul
xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding" >
<soap:Body xmlns:m="http://www.example.org/stock">
, <m:GetStockPriceResponse>
<m:Harga>34.5</m:Harga>
, </m:GetStockPriceResponse>
</soap:Body>
</soap:Sampul>