Types of Web Services

There are 2 types of web services :

  • SOAP web services
  • RESTful web services

SOAP Web services:

  • SOAP stands for Simple Object Access Protocol.
  • SOAP is the standard messaging protocol used by Web services.
  • It is a lightweight XML based messaging protocol intended for exchanging structured information in a decentralized, distributed environment.
  • SOAP’s primary application is inter application communication.
  • SOAP specifications provide a formal set of conventions that governs how SOAP messages are generated and accepted by SOAP nodes (i.e., senders, receivers and intermediaries).
  • SOAP codifies the use of XML as an encoding scheme for request and response parameters using HTTP as a means for transport.
  • Like XML, SOAP also is independent of the application object model, language, and running platforms or devices.

A SOAP message is enclosed in a SOAP envelope that contains a SOAP header and a SOAP body. The SOAP body is mandatory, whereas the SOAP header is optional. The SOAP message is the basic unit of communication between SOAP nodes.

Fig : SOAP Messaging

Below is a sample SOAP Message Request :

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"


SOAP covers the following four main areas:

  • A message format for one-way communication describing how a message can be packed into an XML document.
  • A description of how a SOAP message should be transported using HTTP (for Webbased interaction) or SMTP (for e-mail-based interaction).
  • A set of rules that must be followed when processing a SOAP message and a simple classification of the entities involved in processing a SOAP message.
  • A set of conventions on how to turn an RPC call into a SOAP message and back.

Advantages of SOAP :

  • Simplicity : Based on highly-structured format of XML
  • Portability: No dependencies on underlying platform
  • Firewall friendliness : By posting data over HTTP
  • Use of open standards : text-based XML standard
  • Interoperability : Built on open technologies (XML and HTTP)
  • Universal acceptance : Most widely accepted message communication standard

Disadvantages of SOAP :

  • much reliance on HTTP : limited only to request/response model and HTTP's slow protocol causes bad performance.
  • Statelessness : difficult for transactional and business processing applications.
  • Serialization by value and not by reference : impossible to refer or point to external data source.

RESTful Web services:

  • REST stands for Representational State Transfer and is an architectural style for designing distributed hypermedia systems.
  • The fundamental concept of a REST-based system is the resource, which can be identified by a Uniform Resource Identifier (URI).
  • For web-based systems, HTTP is the most commonly used protocol for communicating with external systems. You can identify a unique resource using a URI.

For example, a blog post can be identified by the URI. A resource can be a single resource or can be a collection of resources. The various operations that can be performed on a resource can be expressed using its URI along with the appropriate HTTP method (GET, POST, PUT, DELETE, etc).

Fig : REST Messaging

Following the REST principles, you can use the following HTTP verbs:

  • GET — To get a collection or a single resource
  • POST — To create a new resource
  • PUT — To update an existing resource
  • DELETE — To delete a collection or a single resource

The most commonly used data exchange formats (ContentTypes) are JSON and XML.

Advantages of RESTful services :

  • Lightweight :

    One of the main benefits of REST APIs is that they rely on the HTTP standard, which means it’s format-agonistic and you can use XML, JSON, HTML, etc. This makes REST APIs fast, and lightweight — which is necessary for mobile app projects, internet of things devices, and more.

  • Independent :

    Another benefit of REST APIs is the fact that the client and server are independent. In other words, the REST protocol separates the data storage and the UI from the server. This means that developers can work on different areas of a project independently and try out multiple developer environments as needed.

  • Scalable and flexible :

    One of the third benefits of REST APIs, and perhaps one of the most important, is scalability and flexibility . REST APIs can be scaled quickly primarily due to the separation between the client and the server. Additionally, developers can also easily integrate REST APIs without much added work.

Disadvantages of RESTful services :

  • Lack of state :

    most web applications require stateful mechanisms. Suppose you purchase a website which has a mechanism to have a shopping cart. It is required to know the number of items in the shopping cart before the actual purchase is made. This burden of maintaining the state lies on the client, which makes the client application heavy and difficult to maintain.

  • Last of security :

    REST doest impose security such as SOAP. That is the reason REST is appropriate for public URLs, but it is not good for confidential data passage between client and server.