Skip to content

Instantly share code, notes, and snippets.

@amelieykw
Last active July 19, 2018 08:57
Show Gist options
  • Save amelieykw/607cd540195b2e94faee3138beadb306 to your computer and use it in GitHub Desktop.
Save amelieykw/607cd540195b2e94faee3138beadb306 to your computer and use it in GitHub Desktop.
[RPC, RMI, SOAP - REST web service] #RPC #RMI #SOAP #REST #webService

SOAP:

  • Simple Object Access Protocol
  • XML-based messaging protocol for exchanging information among computers
  • an application of the XML specification

the initial focus of SOAP is remote procedure calls transported via HTTP.

Other frameworks including CORBA, DCOM, and Java RMI provide similar functionality to SOAP, but SOAP messages are written entirely in XML and are therefore uniquely platform- and language-independent.

SOAP Message Structure

A SOAP message is an ordinary XML document containing the following elements −

  • Envelope − Defines the start and the end of the message. It is a mandatory element.
  • Header − Contains any optional attributes of the message used in processing the message, either at an intermediary point or at the ultimate end-point. It is an optional element.
  • Body − Contains the XML data comprising the message being sent. It is a mandatory element.
  • Fault − An optional Fault element that provides information about errors that occur while processing the message.

The following block depicts the general structure of a SOAP message −

<?xml version = "1.0"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV = "http://www.w3.org/2001/12/soap-envelope" 
   SOAP-ENV:encodingStyle = "http://www.w3.org/2001/12/soap-encoding">

   <SOAP-ENV:Header>
      ...
      ...
   </SOAP-ENV:Header>
   <SOAP-ENV:Body>
      ...
      ...
      <SOAP-ENV:Fault>
         ...
         ...
      </SOAP-ENV:Fault>
      ...
   </SOAP-ENV:Body>
</SOAP_ENV:Envelope>

SOAP request

POST /Quotation HTTP/1.0
Host: www.xyz.org
Content-Type: text/xml; charset = utf-8
Content-Length: nnn

<?xml version = "1.0"?>
<SOAP-ENV:Envelope
   xmlns:SOAP-ENV = "http://www.w3.org/2001/12/soap-envelope"
   SOAP-ENV:encodingStyle = "http://www.w3.org/2001/12/soap-encoding">

   <SOAP-ENV:Body xmlns:m = "http://www.xyz.org/quotations">
      <m:GetQuotation>
         <m:QuotationsName>MiscroSoft</m:QuotationsName>
      </m:GetQuotation>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

A corresponding SOAP response

HTTP/1.0 200 OK
Content-Type: text/xml; charset = utf-8
Content-Length: nnn

<?xml version = "1.0"?>
<SOAP-ENV:Envelope
   xmlns:SOAP-ENV = "http://www.w3.org/2001/12/soap-envelope"
   SOAP-ENV:encodingStyle = "http://www.w3.org/2001/12/soap-encoding">

   <SOAP-ENV:Body xmlns:m = "http://www.xyz.org/quotation">
      <m:GetQuotationResponse>
         <m:Quotation>Here is the quotation</m:Quotation>
      </m:GetQuotationResponse>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment