|
|
what is soap?
What is SOAP?
Why SOAP?
SOAP Example
|
| What is SOAP?
|
|
SOAP stands for Simple Object Access Protocol and is an XML-based communication protocol for exchanging information
between computers. Although SOAP can be used in a variety of messaging systems and can be delivered via a variety
of transport protocols, the main focus of SOAP is Remote Procedure Calls (RPC) transported via HTTP. SOAP is
platform and language independent and therefore enables diverse applications to communicate with one another.
|
|
| Why SOAP?
|
|
SOAP is important for application development as it allows Internet communication between programs.
Applications can communicate using Remote Procedure Calls (RPC) between objects using technologies,
such as DCOM and CORBA. RPC represents a compatibility and security problem as firewalls and
proxy servers will normally block this kind of traffic.
A better way to communicate between applications is over HTTP because HTTP is supported by all Internet
browsers and servers. SOAP was created to accomplish this. SOAP provides a way to communicate between
applications running on different operating systems, with different technologies and programming languages.
|
|
| SOAP Example?
|
Figure 1 shows a sample SOAP request to a stock quote service.
POST /InStock HTTP/1.1
Host: www.stock.org
Content-Type: application/soap+xml; charset=utf-8
Content-Length: 3
<?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.stock.org/stock">
<m:GetStockPrice>
<m:StockName>IBM</m:StockName>
</m:GetStockPrice>
</soap:Body>
</soap:Envelope>
|
Figure 1: Example SOAP Request
The request makes use of both XML namespaces and XML Schemas. The body of the request specifies both
a method name (GetStockPrice) and a list of parameters (StockName).
Figure 2 shows a sample SOAP response from the stock quote service.
HTTP/1.1 200 OK
Content-Type: application/soap; charset=utf-8
Content-Length: 4
<?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.stock.org/stock">
<m:GetStockPriceResponse>
<m:Price>34.5</m:Price>
</m:GetStockPriceResponse>
</soap:Body>
</soap:Envelope>
|
Figure 2: Example SOAP Response
The response indicates a currency return value (the current stock price).
|
|
|
|
|
|