A Web Service is can be understand more clear way with below….
- Its a client server application.
- Method of communication between two devices over network.
- Its a collection of standards/protocols for exchanging information between two devices or application.
- Its a software system for interoperable machine to machine information exchange.
Understand it by the figure given below:
java, .net or PHP applications can communicate with other applications through web service over the network.
Ex:java application can interact with Java, .Net and PHP applications. So web service is a language independent way of communication.
Types of Web Services
we have 2 types of web services.
- SOAP web services.
- RESTful web services.
SOAP Web Services
SOAP provides the envelope for sending Web Services messages over the Internet/Internet. It is part of the set of standards specified by the W3C. SOAP is an alternative to Representational State Transfer (REST) and JavaScript Object Notation (JSON).
The SOAP envelope contains two parts:
- An optional header providing information on authentication, encoding of data, or how a recipient of a SOAP message should process the message.
- The body that contains the message. These messages can be defined using the WSDL specification.
SOAP commonly uses HTTP, but other protocols such as Simple Mail Transfer Protocol (SMTP) may by used. SOAP can be used to exchange complete documents or to call a remote procedure.
NOTE: SOAP at one time stood for Simple Object Access Protocol. Starting with SOAP Version 1.2, the letters in the acronym have no particular meaning.
Advantages :
- SOAP defines its own security known as WS Security.
- SOAP web services can be written in any programming language and executed in any platform.
Disadvantages:
- 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.
- SOAP uses WSDL and doesn’t have any other mechanism to discover the service.
RESTful Web Services
REST is used to build Web services that are lightweight, maintainable, and scalable in nature.
The underlying protocol for REST is HTTP, which is the basic web protocol. REST stands for REpresentational State Transfer
Restful Methods
The below pictorial diagram shows mostly all the verbs (POST, GET, PUT, and DELETE)
When the client makes any request to this web service, it can specify any of the normal HTTP verbs of GET, POST, DELETE and PUT. Below is what would happen If the respective verbs were sent by the client.
- POST – This would be used to create a new employee using the RESTful web service
- GET – This would be used to get a list of all employee using the RESTful web service
- PUT – This would be used to update all employee using the RESTful web service
- DELETE – This would be used to delete all employee using the RESTful web service
The following actions would have their respective meanings.
- POST – This would not be applicable since we are fetching data of employee 1 which is already created.
- GET – This would be used to get the details of the employee with Employee no as 1 using the RESTful web service
- PUT – This would be used to update the details of the employee with Employee no as 1 using the RESTful web service
- DELETE – This is used to delete the details of the employee with Employee no as 1
Finally Differences…….
S.No | SOAP | REST |
1 | SOAP is a protocol. | 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 | SOAP defines standards to be strictly followed. | REST does not define too much standards like SOAP. |
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. |
No comments:
Post a Comment