SOAP (protocol): Difference between revisions
imported>Pat Palmer mNo edit summary |
imported>Pat Palmer (→Sample SOAP message: replacing this example with a simpler one) |
||
Line 33: | Line 33: | ||
</soap12:Body> | </soap12:Body> | ||
</soap12:Envelope> | </soap12:Envelope> | ||
Revision as of 03:57, 26 December 2011
SOAP is a client-server protocol for RPC messaging between a web service and its clients on the web. The protocol's request and response format is XML, and the messages are usually carried on top of HTTP. The SOAP specification grew out of an industry consortium soon after 2000; it relies on compilers to automatically read a web service contract (WSDL file) at compile time, and generate a proxy object. The local computer program communicates with the proxy object as if it were a local object, and the proxy object automatically handles all the RPC-style SOAP messaging between server and client.
SOAP also refers to a dialect (encoding) of XML; SOAP-encoded XML is designed to be more concise that pure XML by providing pointer attributes for any duplicated data values. However, SOAP-encoded XML was not popular for use in SOAP protocol messaging, and after early experiments, pure XML became widely preferred as the SOAP protocol message format.
The name SOAP was originally defined as Simple Object Access Protocol, but this acronym fell out of favor as incorrectly representing the protocol.
The following is a sample SOAP 1.2 request and response, shown as the payload of an HTTP request and response message. The request calls a web service method, GetQuote, which requires no input parameters. The string in the SOAP response envelope is a placeholder and would be replaced, at run time, with an actual quote returned by the server:
POST /quotes/Quote.asmx HTTP/1.1 Host: harbormist.com Content-Type: application/soap+xml; charset=utf-8 Content-Length: length
<?xml version="1.0" encoding="utf-8"?> <soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"> <soap12:Body> <GetQuote xmlns="HarborMist" /> </soap12:Body> </soap12:Envelope>
HTTP/1.1 200 OK Content-Type: application/soap+xml; charset=utf-8 Content-Length: length
<?xml version="1.0" encoding="utf-8"?> <soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"> <soap12:Body> <GetQuoteResponse xmlns="HarborMist"> <GetQuoteResult>string</GetQuoteResult> </GetQuoteResponse> </soap12:Body> </soap12:Envelope>