Introduction to RESTful Web ServicesREST stands for REpresentational State Transfer. It is developed by Roy Thomas Fielding, who also developed HTTP. The main goal of RESTful web services is to make web services more effective. RESTful web services try to define services using the different concepts that are already present in HTTP. REST is an architectural approach, not a protocol. It does not define the standard message exchange format. We can build REST services with both XML and JSON. JSON is more popular format with REST. The key abstraction is a resource in REST. A resource can be anything. It can be accessed through a Uniform Resource Identifier (URI). For example: The resource has representations like XML, HTML, and JSON. The current state capture by representational resource. When we request a resource, we provide the representation of the resource. The important methods of HTTP are:
For example, if we want to perform the following actions in the social media application, we get the corresponding results. POST /users: It creates a user. GET /users/{id}: It retrieves the detail of a user. GET /users: It retrieves the detail of all users. DELETE /users: It deletes all users. DELETE /users/{id}: It deletes a user. GET /users/{id}/posts/post_id: It retrieve the detail of a specific post. POST / users/{id}/ posts: It creates a post of the user. Further, we will implement these URI in our project. HTTP also defines the following standard status code:
RESTful Service Constraints
Advantages of RESTful web services
|