Types of Web Services
There are two types of web services:
- 1. SOAP Web Services
- 2. REST Web Services
SOAP Web Services
SOAP is an XML-based protocol. The biggest advantage of using the SOAP Web Service is its own security. SOAP stands for Simple Object Access Protocol.
SOAP provides an envelope to send a web services messages over the Internet, using the HTTP protocol. The messages are generally in XML format.
In simple words, SOAP is a technique to send an XML request over the Internet using HTTP protocol (hitting a URL), and in return getting an XML response.
Taking a real world example, if a client wants to fetch a college's student data, by sending in the student's Roll No. in the request, he can do so using web services. But how will the client know, which URL to call and what to send in the request?
Well, every application serving SOAP requests, has a WSDL file. WSDL is an XML, and it stands for Web Service Description Language. WSDL describes all the methods available in the web service, along with the request and response types. It describes the contract between service and client.
SOAP was intended to be a way to do remote procedure calls to remote objects by sending XML over HTTP.
If we look at the current software industry, you will find that, SOAP is being used in the enterprise applications, generally in the legacy code. Today the world is moving fast towards the RESTful Web Services.
MIND IT !
Advantages of Soap Web Services
WS Security: SOAP defines its own security known as WS Security.
Language and Platform independent: SOAP web services can be written in any programming language and executed in any platform.
Disadvantages of Soap Web Services
Slow: 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.
WSDL dependent: SOAP uses WSDL and doesn't have any other mechanism to discover the service.
REST Web Services
The REST stands for Representational State Transfer. REST is not a set of standards or rules, rather it is a style of software architecture. The applications which follow this architecture are referred to as RESTful
Unlike SOAP which targets the actions, REST concerns more on the resources. REST locates the resources by using URL and it depends on the type of transport protocol(with HTTP - GET, POST, PUT, DELETE,...) for the actions to be performed on the resources. The REST service locates the resource based on the URL and performs the action based on the transport action verb. It is more of architectural style and conventions based.
For Example: in a RESTful architecture, the below URL can be used to:
- 1. To get student information by sending a REST call of GET type, and the service will return information of student with roll no as
- 2. The same service can also be used to update the student data, by sending in the new values as Form data in a PUT request.
MIND IT !
Advantages of RESTful Web Services
Fast: RESTful Web Services are fast because there is no strict specification like SOAP. It consumes less bandwidth and resource.
Language and Platform independent: RESTful web services can be written in any programming language and executed in any platform.
Can use SOAP: RESTful web services can use SOAP web services as the implementation.
Permits different data format: RESTful web service permits different data format such as Plain Text, HTML, XML and JSON.
SOAP vs REST Web Services
There are many differences between SOAP and REST web services. The important 10 differences between SOAP and REST are given below:
|1)||SOAP is a protocol or a set of standards.||REST is an architectural style.|
|2)||SOAP stands for Simple Object Access Protocol.||REST stands for REpresentational State Transfer.|
|3)||SOAP can't use REST because it is a protocol.||REST can use SOAP web services because it is a concept and can use any protocol like HTTP, SOAP.|
|4)||SOAP uses services interfaces to expose the business logic.||REST uses URI to expose business logic.|
|5)||JAX-WS is the java API for SOAP web services.||JAX-RS is the java API for RESTful web services.|
|6)||SOAP defines standards to be strictly followed.||REST does not define too much standards like SOAP.|
|7)||SOAP requires more bandwidth and resource than REST.||REST requires less bandwidth and resource than SOAP.|
|8)||SOAP defines its own security.||RESTful web services inherits security measures from the underlying transport.|
|9)||SOAP permits XML data format only.||REST permits different data format such as Plain text, HTML, XML, JSON etc.|
|10)||SOAP is less preferred than REST.||REST more preferred than SOAP.|