Representational State Transfer
From Seo Wiki - Search Engine Optimization and Programming Languages
Representational state transfer (REST) is a style of software architecture for distributed hypermedia systems such as the World Wide Web. The term Representational State Transfer (REST) was introduced and defined in 2000 by Roy Fielding in his doctoral dissertation. Fielding is one of the principal authors of the Hypertext Transfer Protocol (HTTP) specification versions 1.0 and 1.1.
Conforming to the REST constraints is often referred to as being ‘RESTful’.
The REST architectural style was developed in parallel with the HTTP/1.1 protocol, based on the existing design of HTTP/1.0. The largest known implementation of a system conforming to the REST architectural style is the World Wide Web. In fact, REST can be considered as a post-hoc description of the features of the Web that made the Web successful. REST exemplifies how the Web's architecture emerged by characterizing and constraining the macro-interactions of the four components of the Web, namely *origin servers, *gateways, *proxies and *clients, without imposing limitations on the individual participants. As such, REST essentially governs the proper behavior of participants.
REST-style architectures consist of clients and servers. Clients initiate requests to servers; servers process requests and return appropriate responses. Requests and responses are built around the transfer of "representations" of "resources". A resource can be essentially any coherent and meaningful concept that may be addressed. A representation of a resource is typically a document that captures the current or intended state of a resource.
At any particular time, a client can either be transitioning between application states or "at rest". A client in a rest state is able to interact with its user, but creates no load and consumes no per-client storage on the set of servers or on the network.
The client begins sending requests when it is ready to transition to a new state. While one or more requests are outstanding, the client is considered to be transitioning states. The representation of each application state contains links that may be used next time the client chooses to initiate a new state transition.
REST was initially described in the context of HTTP, but is not limited to that protocol. RESTful architectures can be based on other Application Layer protocols if they already provide a rich and uniform vocabulary for applications based on the transfer of meaningful representational state. RESTful applications maximise the use of the pre-existing, well-defined interface and other built-in capabilities provided by the chosen network protocol, and minimise the addition of new application-specific features on top of it.
HTTP, for example, has a very rich vocabulary in terms of verbs (or 'methods'), URIs, request and response headers, Internet media types, HTTP request and response codes etc. REST over HTTP works with and leverages these existing features, and thus allows existing layered proxy and gateway components to perform additional functions on the network such as HTTP caching and security enforcement.
SOAP RPC contrast
SOAP RPC over HTTP, on the other hand, encourages each application designer to define a new and arbitrary vocabulary of nouns and verbs (for example
savePurchaseOrder(...)), usually overlaid onto the HTTP 'POST' verb. This disregards many of HTTP's existing capabilities such as authentication, caching, content type negotiation, etc. and may leave the application designer re-inventing many of these features within the new vocabulary. Examples of doing so may include the addition of methods such as
savePurchaseOrder(string customerLogon, string password, ...).
The REST architectural style describes the following six constraints applied to the architecture, while leaving the implementation of the individual components free to design:
- Clients are separated from servers by a uniform interface. This separation of concerns means that, for example, clients are not concerned with data storage, which remains internal to each server, so that the portability of client code is improved. Servers are not concerned with the user interface or user state, so that servers can be simpler and more scalable. Servers and clients may also be replaced and developed independently, as long as the interface is not altered.
- The client-server communication is further constrained by no client context being stored on the server between requests. Each request from any client contains all of the information necessary to service the request, and any state is held in the client. This not only makes servers more visible for monitoring, but also makes them more reliable in the face of partial or network failures as well as further enhancing their scalability.
- As on the World Wide Web, clients are able to cache responses. Responses must therefore, implicitly or explicitly, define themselves as cacheable or not to prevent clients reusing stale or inappropriate data in response to further requests. Well-managed caching partially or completely eliminates some client-server interactions, further improving scalability and performance.
- 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 may improve system scalability by enabling load balancing and by providing shared caches. They may also enforce security policies.
- Code on demand (optional)
- Uniform interface
- The uniform interface between clients and servers, discussed below, simplifies and decouples the architecture, which enables each part to evolve independently. The four guiding principles of this interface are detailed below.
The only optional constraint of REST architecture is code on demand. If a service violates any other constraint, it cannot strictly be referred to as RESTful.
Complying with these constraints, and thus conforming to the REST architectural style, will enable any kind of distributed hypermedia system to have desirable emergent properties, such as performance, scalability, simplicity, modifiability, visibility, portability and reliability.
Guiding principles of a REST interface
The uniform interface that any REST interface must provide is considered fundamental to the design of any REST service.
- Identification of resources
- Individual resources are identified in requests, for example using URIs in web-based REST systems. The resources themselves are conceptually separate from the representations that are returned to the client. For example, the server does not send its database, but rather, perhaps, some HTML, XML or JSON that represents some database records expressed, for instance, in French and encoded in UTF-8, depending on the details of the request and the server implementation.
- Manipulation of resources through these representations
- When a client holds a representation of a resource, including any metadata attached, it has enough information to modify or delete the resource on the server, provided it has permission to do so.
- Self-descriptive messages
- Each message includes enough information to describe how to process the message, for example which parser to invoke. An example of this is the use of Internet media types, previously known as MIME types. From the media type alone, the client must know how to process its contents. If it needs to look inside the message's contents in order to understand it, the message is not self-descriptive. For example, merely using the "application/xml" media type is not sufficient for knowing what to do with its contents, unless code-download is used.
- Hypermedia as the engine of application state
- If it is likely that the client will want to access related resources, these should be identified in the representation returned, for example by providing their URIs in sufficient context, such as hypertext links.
Key goals of REST
Key goals of REST include:
- Scalability of component interactions;
- Generality of interfaces;
- Independent deployment of components;
- Intermediary components to reduce latency, enforce security and encapsulate legacy systems
REST has been applied to describe the desired Web architecture, helped to identify existing problems, to compare alternative solutions, and to ensure that protocol extensions would not violate the core constraints that make the Web successful.
Fielding describes REST's effect on scalability thus:
REST's client-server separation of concerns simplifies component implementation, reduces the complexity of connector semantics, improves the effectiveness of performance tuning, and increases the scalability of pure server components. Layered system constraints allow intermediaries—proxies, gateways, and firewalls—to be introduced at various points in the communication without changing the interfaces between components, thus allowing them to assist in communication translation or improve performance via large-scale, shared caching. REST enables intermediate processing by constraining messages to be self-descriptive: interaction is stateless between requests, standard methods and media types are used to indicate semantics and exchange information, and responses explicitly indicate cacheability.
REST's central principle: resources
An important concept in REST is the existence of resources (sources of specific information), each of which is referenced with a global identifier (e.g., a URI in HTTP). In order to manipulate these resources, components of the network (user agents and origin servers) communicate via a standardized interface (e.g., HTTP) and exchange representations of these resources (the actual documents conveying the information). For example, a resource that represents a circle may accept and return a representation that specifies a center point and radius, formatted in SVG, but may also accept and return a representation that specifies any three distinct points along the curve as a comma-separated list.
Any number of connectors (e.g., clients, servers, caches, tunnels, etc.) can mediate the request, but each does so without "seeing past" its own request (referred to as "layering," another constraint of REST and a common principle in many other parts of information and networking architecture). Thus, an application can interact with a resource by knowing two things: the identifier of the resource and the action required—it does not need to know whether there are caches, proxies, gateways, firewalls, tunnels, or anything else between it and the server actually holding the information. The application does, however, need to understand the format of the information (representation) returned, which is typically an HTML, XML or JSON document of some kind, although it may be an image, plain text, or any other content.
RESTful web services
A RESTful web service (also called a RESTful web API) is a simple web service implemented using HTTP and the principles of REST. Such a web service can be thought about as a collection of resources. The definition of such a web service can be thought of as comprising three aspects:
- The base URI for the web service, such as
- The MIME type of the data supported by the web service. This is often JSON, XML or YAML but can be any other valid MIME type.
- The set of operations supported by the web service using HTTP methods (e.g., POST, GET, PUT or DELETE).
The following table shows how the HTTP verbs are typically used to implement a web service.
| Collection URI, such as ||List the members of the collection, complete with their member URIs for further navigation. For example, list all the cars for sale.||Meaning defined as "replace the entire collection with another collection".||Create a new entry in the collection where the ID is assigned automatically by the collection. The ID created is usually included as part of the data returned by this operation.||Meaning defined as "delete the entire collection".|
| Element URI, such as ||Retrieve a representation of the addressed member of the collection expressed in an appropriate MIME type||Update the addressed member of the collection or create it with the specified ID.||Treats the addressed member as a collection in its own right and creates a new subordinate of it.||Delete the addressed member of the collection.|
Unlike SOAP-based web services, there is no "official" standard for RESTful web service. This is because REST is an architecture, unlike SOAP, which is a protocol. Even though REST is not a standard, a RESTful implementation such as the Web can use standards like HTTP, URL, XML, PNG, etc.
REST can be found in a number of places on the public Web:
- The Atom Publishing Protocol for publishing to blogs is considered a canonical RESTful protocol;
- Sun Microsystems's Cloud API is a good example of resource media type documentation.
- The Open Services for Lifecycle Collaboration (OSLC) initiative is establishing a RESTful approach to integrating software development artifacts.
- CouchDB is a document-oriented database written in Erlang that provides a RESTful JSON API that can be accessed from any environment that allows HTTP requests.
- Microsoft's Azure Services Platform
- Microsoft's WCF Data Services ADO.NET Data Services
- .net Open-Source - OpenRasta 
- TurboGears2 provides a RestController 
- Python RIP
- Ruby Sinatra, Ruby On Rails, Restfulie
- Java Restlet, JBoss RESTEasy, Jersey, Apache CXF, NetKernel, Apache Sling , Restfulie Java, JRest-Route
- REST microkernel and software platform NetKernel
- PHP Recess! Framework, Symfony, Zend Framework, CakePHP, CodeIgniter, Yii Framework,(w/ Phil Sturgeon's Library)
- Perl Catalyst REST
- Perl p2ee Framework and Applications
- Ext JS 3.0 Ext JS 3.0 RC2 Release – Stable, Robust, and Enhanced
Outside of the Web
Software that may interact with a number of different kinds of objects or devices can do so by virtue of a uniform, agreed interface.
The Common Management Information Protocol (CMIP) was designed to allow the control of network resources by presenting their manageable characteristics as object attributes. The objects have parent-child relationships that are identified using distinguished names and attributes, which are read and modified by a set of CRUD operations. The notable non-restful aspect of CMIP is the M_ACTION operation although, wherever possible, designers of management information bases (MIBs) would typically endeavour to represent controllable and stateful aspects of network equipment through attributes.
Architectural styles originating from REST
Several architectural styles have been developed as modifications or extensions of REST.
CREST (Computational REST) is a new architectural style which, as a generalization of REST, recasts the web from a model where content is the fundamental measure of exchange to a model where computational exchange is the primary mechanism.
- ↑ Chapter 5 of Fielding's dissertation is "Representational State Transfer (REST)".
- ↑ "Roy discussing the definition of the REST term"
- ↑ Roy discusses the development of the REST style
- ↑ Roy talks about application states
- ↑ 5.0 5.1 Scribner, Kenn; Seely, Scott (2009). Effective REST Services via .NET. Boston: Addison-Wesley. ISBN 978-0-321-61325-7.
- ↑ Template:Harv
- ↑ Richardson, Leonard; Ruby, Sam (2007), RESTful Web Services, O'Reilly (published (May 8, 2007)), ISBN 0596529260
- ↑ Elkstein, M. What is REST?. Retrieved on 2009-07-04.
- ↑ Web site of Rohit Khare with a link to his dissertation on ARRESTED
- ↑ CREST Web site of Justin Erenkrantz with a link to his dissertation on CREST
- Fielding, Roy T.; Taylor, Richard N. (2002-05), "Principled Design of the Modern Web Architecture" (PDF), ACM Transactions on Internet Technology (TOIT) (New York: Association for Computing Machinery) 2 (2): 115–150, doi:10.1145/514183.514185, ISSN 1533-5399, http://www.ics.uci.edu/~taylor/documents/2002-REST-TOIT.pdf
- Fielding, Roy Thomas (2000), Architectural Styles and the Design of Network-based Software Architectures, Doctoral dissertation, University of California, Irvine, http://www.ics.uci.edu/~fielding/pubs/dissertation/top.htm
- Pautasso, Cesare; Zimmermann, Olaf; Leymann, Frank (2008-04), "RESTful Web Services vs. Big Web Services: Making the Right Architectural Decision", 17th International World Wide Web Conference (WWW2008) (Beijing, China), http://www.jopera.org/docs/publications/2008/restws
|This article's external links may not follow Wikipedia's policies or guidelines. Please improve this article by removing excessive and inappropriate external links or by converting links into references. (July 2009)|
- REST Article in Spanish
- "Stefan Tilkov: A Brief Introduction to REST"
- "Stefan Tilkov: Addressing REST Doubts"
- "Stefan Tilkov: REST Anti-Patterns"
- "Gregor Roth: RESTful HTTP in practice"
- The REST Dialogues, Part 1: "Getting Data": one of nine lessons on applying REST to Web-based business, each lesson in the form of dialog between the author and a fictitious senior technical employee of a company conducting Web-based business.
- RESTwiki: a useful collection of articles about REST by some of its early proponents
- "Microsoft ADO.NET Data Services (formerly Project Codename Astoria) for REST"
- "RESTful Web Services with JSP": Tutorial for easy RESTful Web Service with JSP
- "JSON,XML REST API with Microsoft WCF ": Tutorial about how to build XML,JSON REST API service with Microsoft WCF
- "XHTML, JSON, XML, HELP REST API with Microsoft ASP.Net MVC": Tutorial about how to build XHTML, JSON, XML, HELP REST API service with Microsoft ASP.Net MVC
- From SOA to REST (WWW 2009 Tutorial)
- restcgi: Open source Common Gateway Interface C++ library
- How I Explained REST to My Wife: Simple explanation of what REST is and why it's important
- Validating an email address using REST: A simple example you can run from a browser to help explain REST
de:Representational State Transfer es:Representational State Transfer fr:Representational State Transfer ko:REST id:REST it:Representational State Transfer he:REST ja:REST pl:REST pt:REST ru:REST sv:Representational State Transfer zh:REST