LM Tech's blog

Software Architecture & Design Patterns
Feb
02

RESTful Web Service

by lma | Tags:

A RESTful Web Service is a web service that implemed the REST architectural style.

The RESTful web API defines a set of standards to interact with resources on the web:

URI (Uniform Resource Identifier)

Identifies in a unique way a resource on the web (ex. http://mysite.com/resources/resource_name ).

MIME Type

Internet Media Type of the data (ex. XML, HTML, JSON).

HTTP Methods (request methods)

Standard methods that can be applied to the specified resource:

GET (requests a specific representation of a resource)
PUT (create or update a resource with the supplied representation)
DELETE (deletes the specified resource)
POST (submits data to be processed by the identified resource)



Representational State Transfer (REST) is a style of software architecture for distributed systems such as the World Wide Web. REST is based on Resources that are identified by a unique URI.
REST is not tied to any particular technology or platform - it’s simply a way to design things to work like the Web. People often refer to services that follow this philosophy as "RESTful services".

The REST architectural style is based on the following constraints:

Client-server
A uniform interface separates clients from servers, so we can speak of "separation-of-concerns". Servers are not concerned with the user interface, so that servers can be simpler and more scalable. Servers and clients are loosely coupled and may also be replaced and developed independently, as long as the interface between them is not altered.

Stateless
Each request to the server should contain all the information required to understand and complete the request.

Cacheable
 As on the World Wide Web, clients can cache responses to improve the performance and reduce network traffic.

Layered system
A client cannot ordinarily tell whether it is connected directly to the end server, or to an intermediary along the way. Intermediary servers like Proxy servers or Cache servers can be used to improve performance or introduce security.

Uniform interface
The uniform interface between clients and servers simplifies and decouples the architecture, which enables each part to evolve independently. HTTP defines a standard set of methods (request methods), status codes, and headers for interacting with resources on the Web.

Common request methods are:

GET (requests a specific representation of a resource)
PUT (create or update a resource with the supplied representation)
DELETE (deletes the specified resource)
POST (submits data to be processed by the identified resource)