What is WebService? Why it is Needed?

Features of web services


  1. As web services are based on open standards like XML, HTTP so these are operating system independent
  2. Likewise web services are programming language independent, a java application can consume a PHP web service
  3. Web services can be published over internet to be consumed by other web applications
  4. The consumer of web service is loosely coupled with the web service, so the web service can update or change their underlying logic without affecting the consumer



Types of Web Services


SOAP Web Service


SOAP stands for Simple Object Access Protocol, it is a standardized protocol for message exchange between web applications. The message format supported by SOAP is XML. A web service that is based on SOAP protocol is called SOAP web service.

RESTful Web services or REST API


REST stands for Representational State Transfer, it is an architectural style that describes some constraint for web service development. A web service that satisfies these constraints is called RESTful web service. The six REST architecture constraints are-


  • Client-Server - Client and server are separated by a uniform interface and are not concerned with each other's internal logic
  • Stateless - Each client request is independent and contains all the necessary information required to get executed. No client data is saved at the server.
  • Cacheable - Client should have the ability to cache the responses
  • Layered System - A layered system having multiple layers wherein each layer communicates with adjacent layer only
  • Uniform Interface - A uniform interface design requires each component within the service to share a single and uniform architecture
  • Code on Demand - This constraint is optional. It extends client side execution of code transfer of executable scripts like javascript from server.

RESTful APIs implements the following types of HTTP methods-

  • GET - HTTP GET method is used to retrieve some information
  • POST - HTTP POST method submits and creates new resources
  • PUT - HTTP PUT is used to update an already existing resource
  • DELETE - HTTP DELETE is used to delete a resource



In this tutorial we studied about web services and its type. In the next post we will see the difference between a SOAP and RESTful web service.