RESTful Services
Representational State Transfer (REST) is an architectural style of client-server application centered around the transfer of representations of resources through requests and responses.
RESTful web services are a set of open protocols and standards for sharing data across different applications or systems. The REST Server just gives access to resources, while the REST Client uses the resources to access and modify them. URIs/ global IDs are used to identify each resource. Text, JSON, and XML are some of the representations used by REST to describe a resource. The most well-known is JSON. RESTful web services are lightweight, loosely connected web services that are especially well suited for providing APIs for clients all over the internet.
6 Architectural Constraints of RESTful Services
- Uniform interface
- Client-server
- Stateless
- Cacheable
- Layered system
- Code on demand (optional)
Which principles encourage RESTful applications to be simple, lightweight, and fast
- Resource identification through URI: A RESTful web service exposes a set of resources that identify the targets of the interaction with its clients.
- Uniform interface: Resources are manipulated using a fixed set of four create, read, update, delete operations: PUT, GET, POST, and DELETE.
- Self-descriptive messages: Resources are decoupled from their representation so that their content can be accessed in a variety of formats, such as HTML, XML, plain text, PDF, JPEG, JSON, and others.
- Stateful interactions through hyperlinks: Every interaction with a resource is stateless, which means that requests are self-contained. The idea of explicit state transfer underpins stateful interactions.
Restful Methods
- POST – This would be used to create a new resource using the RESTful web service
- GET - This would be used to get a list of all resources using the RESTful web service
- PUT - This would be used to update all resources using the RESTful web service
- DELETE - This would be used to delete all resources using the RESTful services
The key elements of a RESTful implementation
- Resources: The first key element is the resource itself.
- Request Verbs: These describe what you want to do with the resource.
- Request Headers: Additional instructions sent with the request.
- Request Body: Data is sent with the request.
- Response Body: The main body of the response.
- Response Status codes: These are the typical codes that are returned by the web server along with the response.
HTTP Messages
- HTTP REQUEST
- Verb − Indicates the HTTP methods such as GET, POST, DELETE, PUT, etc.
- URI − Uniform Resource Identifier to identify the resource on the server.
- HTTP Version − Indicates the HTTP version.
- Request Header − Contains metadata for the HTTP Request message as key-value pairs.
- Request Body − Message content or Resource representation.
2. HTTP RESPONSE
- Status/Response Code − Indicates the Server status for the requested resource.
- HTTP Version − Indicates the HTTP version.
- Response Header − Contains metadata for the HTTP Response message as keyvalue pairs.
- Response Body − Response message content or Resource representation.


Comments
Post a Comment