SOAP Web Services

Web services can be implemented with different technologies such as SOAP or REST. Simply, SOAP web services provide a business logic exposed via a service to a client. And it is done by a loosely coupled interface using XML. The interface to which a message is sent defines the format of the message request and response, and mechanisms to publish and to discover web service interfaces.

SOAP usually relies on several technologies and protocols such as HTTP or SMTP for transferring and transforming data. Some of this technologies are:

SOAP

Simple Object Access Protocol is the standard web services application protocol. It provides the communication mechanism to connect web services, exchanging formatted XML data across a network protocol. SOAP relies heavily on XML for defining an extensive messaging framework. This framework is independent of any particular programming model.

SOAP Messages

SOAP message is a one-way message such as a request from a client, or a response from a server. Every SOAP message contains an Envelope element, an optional Header element and a Body element.

SOAP message

Envelope

The SOAP XML Envelope defines specific rules for encapsulating data being transferred between computers. This includes application-specific data, such as the method name to invoke, method parameters, or return values. It can also include information about who should process the envelope contents

Envelope element has:

An example:

<?xml version="1.0"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
  soap:encodingStyle="http://www.w3.org/2003/05/soap-encoding">
  ...
  Message information goes here
  ...
</soap:Envelope>

The encodingStyle attribute is used to define the data types used in the document. This attribute may appear on any SOAP element, and applies to the element's contents and all child elements.

Header

The optional Header element offers a flexible framework for specifying additional application-level requirements (like authentication, payment, etc.) about the SOAP message.

An example:

<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
soap:encodingStyle="http://www.w3.org/2003/05/soap-encoding">

<soap:Header>
<m:Trans xmlns:m="http://www.example.org/transaction/"
soap:mustUnderstand=”true” >
5
</m:Trans>
</soap:Header>
...
</soap:Envelope>

Body

Body element contains the actual message. For example:

<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
soap:encodingStyle="http://www.w3.org/2003/05/soap-encoding">

<soap:Body xmlns:m="http://www.example.org/stock">
  <m:GetStockPrice>
    <m:StockName>IBM</m:StockName>
  </m:GetStockPrice>
</soap:Body>

</soap:Envelope>

A GetStockPrice request is sent to a server. The request has a StockName parameter, and a Price parameter that will be returned in the response