What are web services

A web service is any piece of software that makes itself available over the internet and uses a standardized XML messaging system. XML is used to encode all communications to a web service. For example, a client invokes a web service by sending an XML message, then waits for a corresponding XML response. Web services are web application components. Web services can be published, found, and used on the Web. A web service is an application or data source that is accessible via a standard web protocol (HTTP or HTTPS). Unlike web applications, web services are designed to communicate with other programs, rather than directly with users.

Web Services

  • Are available over the Internet or private (intranet) networks
  • Uses a standardized XML messaging system
  • Are not tied to any one operating system or programming language
  • Are self-describing via a common XML grammar
  • Are discoverable via a simple find mechanism

Web Service Components

There are three major web service components.

1.Simple Object Access Protocol(SOAP)

I will discuss regarding SOAP in the below of this blog.

2. Web Services Description Language(WSDL)

WSDL is a xml document containing information about web services such as method name, method parameter and how to access it. WSDL is a part of UDDI. It acts as a interface between web service applications.

3. Universal Description, Discovery and Integration(UDDI)

UDDI is a XML based framework for describing, discovering and integrating web services. UDDI is a directory of web service interfaces described by WSDL, containing information about web services.

What is SOAP

Simple Objects Access Protocol (SOAP) is a web communication protocol that was designed for Microsoft in 1998.It’s mainly used these days to show online resources and send data over HTTP/HTTPS. It isn’t, though, exclusive to them. Unlike the REST pattern, SOAP only supports the XML data format and strictly adheres to per-defined standards like messaging structure, encoding rules, and a convention for providing procedure requests and responses.

SOAP message structure

A SOAP message is an XML document that consists,

  1. Envelope is the core and essential element of every message, which begins and concludes messages with its tags, enveloping it, hence the name.
  2. Header (optional) determines the specifics, extra requirements for the message, e.g. authentication.
  3. Body includes the request or response.
  4. Fault (optional) shows all data about any errors that could emerge throughout the API request and response.

Advantages of SOAP

1.SOAP defines its own security known as WS Security.

2.SOAP web services can be written in any programming language and executed in any platform.(Language and Platform independent)

Disadvantages of SOAP

1.WSDL dependent which means SOAP uses WSDL and doesn’t have any other mechanism to discover the service.

2. Slow which means SOAP uses XML format that must be parsed to be read. It defines many standards that must be followed while developing the SOAP applications. So it is slow and consumes more bandwidth and resource.

What is REST

REST (Representational State Transfer) is another standard, made in response to SOAP’s shortcomings. It seeks to fix the problems with SOAP and provide a simpler method of accessing web services. REST was designed specifically for working with components such as media components, files, or even objects on a particular hardware device. Any web service that is defined on the principles of REST can be called a RestFul web service. A Restful service would use the normal HTTP verbs of GET, POST, PUT and DELETE for working with the required components.

HTTP Methods

There are 4 basic HTTP Methods we use in requests to interact with resources in a REST system

GET — The GET method is used to retrieve information from the given server using a given URI. Requests using GET should only retrieve data and should have no other effect on the data.

POST — A POST request is used to send data to the server, for example, customer information, file upload, etc. using HTML forms.

PUT — Replaces all current representations of the target resource with the uploaded content.

DELETE — Removes all current representations of the target resource given by a URI.

REST advantages

  1. RESTful Web Services are fast because there is no strict specification like SOAP. It consumes less bandwidth and resource.
  2. Language and Platform independent which means RESTful web services can be written in any programming language and executed in any platform
  3. RESTful web services can use SOAP web services as the implementation.

REST disadvantages

  1. Since there is no contract defined between service and client, it has to be communicated through other means such as documentation or emails.
  2. Since it works on HTTP, there can’t be asynchronous calls.
  3. Sessions can’t be maintained.


Each technique has its own advantages and disadvantages. Hence, it’s always good to understand in which situations each design should be used

When to use SOAP?

SOAP should be used in the following instances

  1. Asynchronous processing and subsequent invocation —If the customer requires a certain degree of reliability and security, the new SOAP 1.2 specification offers a number of additional features, especially in terms of security.
  2. A Formal means of communication —SOAP 1.2 provides strict requirements for this method of connection if both the client and the server agree on the exchange format. An online shopping store, for example, where people can add products to their cart before paying, is an example. Assume that the actual payment is handled by a web server.
    There will be a firm agreement that only the cart item name, unit price, and quantity will be accepted by the web service. If this is the case, it is often preferable to use the SOAP protocol.
  3. Stateful operations —If the program requires state to be managed from one request to another, the SOAP 1.2 specification includes the WS* structure to support you out.

When to use REST?

One of the most highly debatable topics is when REST should be used or when to use SOAP while designing web services. Below are some of the key factors that determine when each technology should be used for web services REST services should be used in the following instances

  • Limited resources and bandwidth — Since SOAP messages are more content-heavy and use much more bandwidth, REST should be used while network bandwidth is constrained.
  • Statelessness — If there is no need to maintain a state of information from one request to another then REST should be used. If you need a proper information flow wherein some information from one request needs to flow into another then SOAP is more suited for that purpose. We can take the example of any online purchasing site. These sites normally need the user first to add items which need to be purchased to a cart. All of the cart items are then transferred to the payment page in order to complete the purchase. This is an example of an application which needs the state feature. The state of the cart items needs to be transferred to the payment page for further processing.
  • Caching — If there is a need to cache a lot of requests then REST is the perfect solution. At times, clients could request for the same resource multiple times. This can increase the number of requests which are sent to the server. By implementing a cache, the most frequent queries results can be stored in an intermediate location. So whenever the client requests for a resource, it will first check the cache. If the resources exist then, it will not proceed to the server. So caching can help in minimizing the amount of trips which are made to the web server.
  • Ease of coding — REST Services are much easier to code and execute than SOAP. REST is the way to go if you need a fast win option for web services.


Associate Software Engineer at Virtusa

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store