Wednesday, December 14, 2022

What is Web service and its different types


Web Service is can be understand more clear way with below….

  1. Its a client server application.
  2. Method of communication between two devices over network.
  3. Its a collection of standards/protocols for exchanging information between two devices or application.
  4. 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.

  1. SOAP web services.
  2. 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).

SOAP envelope

The SOAP envelope contains two parts:

  1. An optional header providing information on authentication, encoding of data, or how a recipient of a SOAP message should process the message.
  2. 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 :

  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.

Disadvantages:

  1. 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.
  2. 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)

RESTful Web Services

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.

  1. POST – This would be used to create a new employee using the RESTful web service
  2. GET – This would be used to get a list of all employee using the RESTful web service
  3. PUT – This would be used to update all employee using the RESTful web service
  4. DELETE – This would be used to delete all employee using the RESTful web service

The following actions would have their respective meanings.

  1. POST – This would not be applicable since we are fetching data of employee 1 which is already created.
  2. GET – This would be used to get the details of the employee with Employee no as 1 using the RESTful web service
  3. PUT – This would be used to update the details of the employee with Employee no as 1 using the RESTful web service
  4. DELETE – This is used to delete the details of the employee with Employee no as 1

Finally Differences…….

S.NoSOAPREST
1SOAP is a protocol.REST is an architectural style.
2SOAP stands for Simple Object Access Protocol.REST stands for REpresentational State Transfer.
3SOAP 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.
4SOAP uses services interfaces to expose the business logic.REST uses URI to expose business logic.
5SOAP defines standards to be strictly followed.REST does not define too much standards like SOAP.
6SOAP defines standards to be strictly followed.REST does not define too much standards like SOAP.
7SOAP requires more bandwidth and resource than REST.REST requires less bandwidth and resource than SOAP.
8SOAP defines its own security.RESTful web services inherits security measures from the underlying transport.
9SOAP permits XML data format only.REST permits different data format such as Plain text, HTML, XML, JSON etc. 
10SOAP is less preferred than REST.REST more preferred than SOAP.

No comments:

Post a Comment

Understanding Wire vs Imperative Apex Method Calls in Salesforce Lightning Web Components (LWC)

Understanding Wire vs Imperative Apex Method Calls in Salesforce Lightning Web Components (LWC) Introduction: Salesforce Lightning Web ...