Introduction
In this article, we will talk about Types of web services but before going on that, let's first talk about what web service is. Web services are web software that uses a defined message protocol in a distributed context. It combines the web-based application across the network via REST, SOAP, WSDL, and UDDI. Java web services, for example, can interface with a web application. Now let's begin.

Types of Web Services
Web services are classified into two types
-
RESTful Web Services
-
SOAP Web Services
RESTful Web Services
REST is an acronym that stands for REpresentational State Transfer. It was created by Roy Thomas Fielding, who also created HTTP. The primary purpose of RESTful web services is to improve the efficiency of online services. RESTful web services attempt to describe services by utilizing the many principles currently existing in HTTP. REST is a design approach, not a protocol.

The standard message exchange format is not defined. REST services may be built using both XML and JSON. With REST, JSON is the more prevalent format. In REST, the key abstraction is a resource. Anything can be considered a resource. It is reachable through a Uniform Resource Identifier (URI). As an example:
The resource is available in XML, HTML, and JSON formats. A representational resource captures the current state. When we request a resource, we supply the resource's representation. HTTP's most significant methods are:
POST: This method generates a new resource.
DELETE: This command deletes the resource.
GET: This command reads a resource.
PUT: It is used to update an existing resource.
For example,
If we conduct the following steps in the social media application, we will receive the following outcomes.
POST /users: This method creates a user.
GET /users/{id}: Retrieves information about a single user.
GET /users: It retrieves all users' information.
DELETE/users: It removes all users.
DELETE /users/{id}: This command deletes a user.
GET /users/{id}/posts/id post_id: It retrieves information about a certain post.
POST/users/{id}/ posts: This method produces a post for a certain user.
GET /users/{id}/post: Retrieve all posts for a certain user.
HTTP specifies the following standard status codes as well:
401: UNAUTHORISED
500: SERVER ERROR
404: RESOURCE NOT FOUND
200: SUCCESS
201: CREATED

RESTful API
REST defines the appearance of the API (application programming interface) through a set of standards that developers must follow while creating their API. When you link to the relevant URL, you should be able to obtain data (resource). In other words, each URL is referred to as a request, and the data you receive is referred to as a response.
A resource from Facebook's API, for example, maybe a photo or a person, each having a unique identification. When a RESTful API is used, the server sends a representation of the status of the requested resource to the client.
Here are some REST API guidelines to follow while establishing API endpoints:
- REST API URIs must always finish with a noun.
- To keep an API URI constant throughout the application, use plurals.
-
HTTP verbs are used to specify the type of activity.
RESTful Service Constraints
- A service provider and a service customer are required.
- The service has no states.
- The outcome of the service must be cacheable.
- The interface is consistent and exposes resources.
- The service's architecture should be tiered.

The Benefits of RESTful Web Services
RESTful web services are platform agnostic.
- It is developed in any programming language and runs on any platform.
- It supports several data formats, such as JSON, text, HTML, and XML.
- It is faster than SOAP since there are no rigorous specifications like SOAP.
- These can be reused.
- These are language-independent.

SOAP Web Services
REST specifies an architectural approach, whereas SOAP restricts the XML format. Data is sent between the service provider and the service consumer via XML. Keep in mind that SOAP and REST are not interchangeable.
SOAP is an abbreviation for Simple Object Access Protocol. It establishes the standard XML format. It also outlines how web services are built. We utilize Web Service Definition Language (WSDL) to describe the request and response XML formats
For instance, we have requested that the Todo application be accessible via the Facebook application. The Todo application receives an XML request from the Facebook application. The Todo app evaluates the request, creates an XML answer, and returns it to the Facebook app.
If we are utilizing SOAP web services, we must adhere to the SOAP structure.
The SOAP-Envelope in the above illustration has a SOAP-Header and a SOAP Body. It comprises meta-information required to identify the request, such as authentication, authorization, signature, and so on. The SOAP-Header parameter is optional. The actual XML content of the request or response is contained in the SOAP-Body. In the event of an error, the response server returns SOAP-Fault.
Also see, Cloud Computing



