Information about Representational State Transfer

Representational State Transfer (REST) is a style of software architecture for distributed hypermedia systems such as the World Wide Web. The term was introduced in the doctoral dissertation of Roy Fielding in 2000,[1] one of the principal authors of the Hypertext Transfer Protocol (HTTP) specification. It has since come into widespread use in the networking community.

REST strictly refers to a collection of network architecture principles that outline how resources are defined and addressed. The term is often used in a looser sense to describe any simple interface that transmits domain-specific data over HTTP without an additional messaging layer such as SOAP or session tracking via HTTP cookies. These two meanings can conflict as well as overlap. It is possible to design any large software system in accordance with Fielding's REST architectural style without using the HTTP protocol and without interacting with the world wide web. It is also possible to design simple XML+HTTP interfaces that do not conform to REST principles, and instead follow a Remote Procedure Call model. The two different uses of the term "REST" cause some confusion in technical discussions.

Systems that follow Fielding's REST principles are often referred to as RESTful; zealous REST advocates call themselves RESTafarians.

Principles

REST's proponents argue that the Web enjoyed the scalability and growth that it has had as a direct result of a few key design principles:
  • Application state and functionality are divided into resources
  • Every resource is uniquely addressable using a universal syntax for use in hypermedia links
  • All resources share a uniform interface for the transfer of state between client and resource, consisting of
  • A constrained set of well-defined operations
  • A constrained set of content types, optionally supporting code-on-demand
  • A protocol that is:
  • Client/Server
  • Stateless
  • Cacheable
  • Layered

REST's central principle: resources

An important concept in REST is the existence of resources (sources of specific information), each of which can be referred to using a global identifier (a URI). In order to manipulate these resources, components of the network (clients and 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 is 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 or XML document of some kind, although it may be an image or any other content.

Claimed benefits

Many of the statements below refer to REST in the specific context of Web Services, as opposed to SOAP. REST was originally defined in Fielding's dissertation in the context of information and media access. Fielding did not originally contrast REST with RPC.

Advocates claim that REST:
  • Provides improved response times and server loading characteristics due to support for caching
  • Improves server scalability by reducing the need to maintain communication state. This means that different servers can be used to handle initial and subsequent requests
  • Requires less client-side software to be written than other approaches, because a single browser can access any application and any resource
  • Depends less on vendor software than mechanisms that layer additional messaging frameworks on top of HTTP
  • Provides equivalent functionality when compared to alternative approaches to communication
  • Does not require a separate resource discovery mechanism, due to the use of hyperlinks in content
  • Provides better long-term compatibility and evolvability characteristics than RPC. This is due to:
  • The capability of document types such as HTML to evolve without breaking backwards- or forwards- compatibility, and
  • The ability of resources to add support for new content types as they are defined without dropping or reducing support for older content types.
REST detractors note the lack of tool support and the scarcity of truly RESTful applications deployed on the web of today. Some claim that REST is applicable to GET, but unproven for other state transfer operations such as PUT. Fielding points out in his thesis that the REST architecture was designed specifically for massive scale hypermedia distribution, and not as a one size fits all architectural style. Indeed what characterizes REST is the constraints that it imposes on a REST based system. POST is often considered the only necessary client-to-server state transfer operation, and is treated as a mechanism to tunnel arbitrary method invocations across HTTP.

Some REST systems have been deployed and gained tools support such as WebDAV which uses not only GET and POST, but also established HTTP methods like HEAD, DELETE, PUT as well as WebDAV-specific HTTP methods: PROPFIND, PROPPATCH, MKCOL, COPY, MOVE, LOCK, and UNLOCK.

One common stumbling block in the dialog on Claimed Benefits is focusing too much on web browser support for REST. Gateways, caching servers, proxies, and other REST connectors are the critical components for system design and REST.

RESTful example: the World Wide Web

The World Wide Web is the key example of a RESTful design. Much of it conforms to the REST principles. The Web consists of the Hypertext Transfer Protocol (HTTP), content types including the Hypertext Markup Language (HTML), and other Internet technologies such as the Domain Name System (DNS).

HTML can include javascript and applets to support code-on-demand, and has implicit support for hyperlinks.

HTTP has a uniform interface for accessing resources, which consists of URIs, methods, status codes, headers, and content distinguished by MIME type.

The most important HTTP methods are POST, GET, PUT and DELETE. These are often compared with the CREATE, READ, UPDATE, DELETE (CRUD) operations associated with database technologies and the cut and paste user interface:[2]

REST CRUD Cut and Paste
POSTCreatePaste After
GETReadCopy
PUTUpdatePaste Over
DELETEDeleteCut


HTTP separates the notions of a web server and a web browser. This allows the implementation of each to vary from the other based on the client/server principle. When used RESTfully, HTTP is stateless. Each message contains all the information necessary to understand the request when combined with state at the resource. As a result, neither the client nor the server needs to remember any communication-state between messages. Any state retained by the server must be modeled as a resource.

The statelessness constraint can be violated in HTTP using cookies to maintain sessions. Fielding notes the risks of privacy leaks and security complications that often arise through the use of cookies, and the confusions and bugs that can result from interactions between cookies and the "back" button in a browser.

HTTP provides mechanisms to control caching, and permits a conversation between web browser and web cache to occur using the same mechanisms as between web browser and web server. No layer can access any conversation other than the one it is immediately involved with.

REST versus RPC

The statements below refer to REST in the context of Web Services, specifically as opposed to SOAP. Note that Fielding's dissertation presents REST in the context of information and media access, not web services. It does not contrast REST to RPC.

REST: Resources - Commands are defined in simple terms: resources to be retrieved, stored / get, set - difficult to do many joins

RPC: Commands - Commands are defined in methods with varying complexity: depending on "standard" - easier (?) to hide complex things behind a method

REST: Nouns - Exchanging resources and concepts

RPC: Verbs - Exchanging methods

Enlarge picture
REST Triangle of nouns, verbs, and content types.


A RESTful web application requires a different design approach from an RPC (Remote procedure call) application. An RPC application is exposed as one or more network objects, each with an often unique set of functions that can be invoked. Before a client communicates with the application it must have knowledge of the object identity in order to locate it and must also have knowledge of the object type in order to communicate with it.

RESTful design constrains the aspects of a resource that define its interface (the verbs and content types). This leads to the definition of fewer types on the network than an RPC-based application but more resource identifiers (nouns). REST design seeks to define a set of resources that clients can interact with uniformly, and to provide hyperlinks between resources that clients can navigate without requiring knowledge of the whole resource set. Server-provided forms can also be used in a RESTful environment to describe how clients should construct a URL in order to navigate to a particular resource.

Example

An RPC application might define operations such as the following:

getUser() addUser() removeUser() updateUser() getLocation() addLocation() removeLocation() updateLocation() listUsers() listLocations() findLocation() findUser()

Client code to access this application may look something like this:

exampleAppObject = new ExampleApp('example.com:1234') exampleAppObject.removeUser('001')

With REST, on the other hand, the emphasis is on the diversity of resources, or nouns; for example, a REST application might define the following resources

http://example.com/users/ http://example.com/users/{user} (one for each user) http://example.com/findUserForm http://example.com/locations/ http://example.com/locations/{location} (one for each location) http://example.com/findLocationForm

Client code to access this application may look something like this:

userResource = new Resource('http://example.com/users/001') userResource.delete()

Each resource has its own identifier noun. Clients start at a single resource such as the user resource that represents themselves, and navigate to location resources and other user resources. Clients work with each resource through standard operations, such as GET to download a copy of the resource's representation, PUT to paste a changed copy over the top of the original, or DELETE to remove the data or state associated with the resource. POST is sometimes used interchangeably with PUT, but can also be seen as a "paste after" rather than a "paste over" request. POST is generally used for actions with side-effects, such as requesting the creation of a purchase order, or adding some data to a collection. Note how each object has its own URL and can easily be cached, copied, and bookmarked.

Uniform interfaces in REST and RPC

The uniform interface allows clients to access data from a range of resources without special code to deal with each one, so long as it is actually uniform. The content returned from a user resource could be the globally standard and RESTful HTML, a less RESTful industry standard representation such as UserML, or an unRESTful application-specific data format. Which content is returned can be negotiated at request time. The content could even be a combination of these representations: HTML can be marked up with Microformats that have general or industry-specific appeal, and these microformats can be extended with application-specific information.

Uniform interfaces reduce the cost of client software by ensuring it is only written once, rather than once per application it has to deal with. Both REST and RPC designs may try to maximise the uniformity of the interface they expose by conforming to industry or global standards. In the RPC model these standards are primarily in the form of standard type definitions and standard choreography. In REST it is primarily the choice of standard content types and verbs that controls uniformity.

Public implementations

It is possible to claim an enormous number of RESTful applications on the Web (just about everything accessible through an HTTP GET request or updateable through HTTP POST). Taken more narrowly, in its sense as an alternative to both Web Services generally and the RPC style specifically, REST can be found in a number of places on the public Web:
  • The 'blogosphere' — the universe of weblogs — is mostly REST-based, since it involves downloading XML files (in RSS, or Atom format) that contain lists of links to other resources;
  • The Atom Publishing Protocol for publishing to blogs is considered the canonical RESTful protocol;
  • Ruby on Rails 1.2 and later offers a REST model.
  • JAX-RS, a Java API for RESTfull services, is under development[3]
  • Various websites and web applications offer REST developer interfaces to data.
The size of the last category is very small (i.e., those that offer the Atom Publishing Protocol plus a handful of others).

Note that WSDL version 2.0 now offer support for binding to all the HTTP request methods (not only GET and POST as in version 1.1).[4]

Implementation challenges

There are examples of website interfaces that label themselves 'REST', but are, in fact, using HTTP to tunnel function calls or which offer a 'POX/HTTP', (Plain Old XML over HTTP) endpoint. These interfaces do not intentionally respect REST's architectural constraints. Some have been called Accidentally RESTful, by a REST expert. The 'accident' of RESTfulness occurs primarily when standalone GETs are used, i.e. when navigating through many GETs in hypermedia style is not supported, and when those GETs simply retrieve data and do not change it.

Implementation is hampered by limited support for HTTP PUT & DELETE in popular development platforms. For example, in the LAMP platform, support for PUT must be added as a module. Web searches offer few examples of how to implement updating database-driven content using PUT. For example, it is nontrivial to create a PHP script to update http://example.com/thing/1 with a PUT message when /thing.php will serve a GET request with XML generated from a database. Most published patterns for updating entities utilize the POST method.

Outside of the Web

Just as much of the web can be seen as RESTful or nearly-RESTful, a number of existing protocols and architectures have RESTful characteristics. Software that may interact with a number of different kinds of objects or devices can do so by virtue of a uniform, agreed interface. Many of these uniform interfaces follow document-oriented REST patterns rather than object-oriented patterns [should expand on and thus clarify this distinction]:
  • Modbus is a protocol that allows memory ranges within PLCs to be addressed. Ranges can be written and read effectively as PUT and GET operations.
  • Java Beans and other systems that perform property-based editing follow the PUT and GET model of the REST architectural style. Rather than write object-specific editor code, the code is written once and can interact with various object types. Resources in this model are defined by the combination of an object identifier and a property name.
  • Document-oriented SOA has several RESTful characteristics
  • Desktop cut and paste is closely related to REST principles. Cursor positions and highlighted selections in the source and target applications define application state or resources. They are operated on by the small set of verbs CUT, COPY and PASTE. Once cut or copied, data is retained in a number of forms so that, when pasted, the richest format understood by both applications is transferred.

References

Fielding, Roy T. & Richard N. Taylor (2002), "Principled design of the modern Web architecture", ACM Transactions on Internet Technology (TOIT) (ACM Press) 2 (2), ISSN 1533-5399

Fielding, Roy T. (2000), Architectural Styles and the Design of Network-based Software Architectures, UC Irvine, <[1]

zur Muehlen, Michael; Jeffrey V. Nickerson & Keith D Swenson (2005-07), "Developing Web Services Choreography Standards-The Case of REST vs. SOAP", Decision Support Systems 40 (1): 9-29, ISSN 0167-9236, <[2] (retrieved on 2007-09-18)

Khare, Rohit (2004-05-27), Extending the Representational State Transfer (REST) architectural style for decentralized systems, Edinburgh, Scotland, ISSN 0270-5257 ISBN 0-7695-2163-0, <[3]

Tenenbaum, Jay M. & Rohit Khare (2005), Business Services Networks: delivering the promises of B2B, Hong Kong: IEEE Press, pp. 8-8

Robie, Jonathan (2006-12), An XQuery Servlet for RESTful Data Services, Boston, Massachusetts, <[4]

Prescod, Paul (2002-02-06), Second Generation Web Services, O'Reilly's XML.com, <[5] (retrieved on 2007-09-18)

Jacobs, Ian & Norman Walsh, eds. (2004-12-14), Architecture of the World Wide Web, vol. 1, W3C, <[6] (retrieved on 2007-09-18)

Richardson, Leonard & Sam Ruby (2007), RESTful Web Services, O'Reilly Publishers, ISBN 0-596-52926-0

Notes

1. ^ [7]
2. ^ IETF RFC 2616 "Hypertext Transfer Protocol -- HTTP/1.1", R. Fielding et al., June 1999
3. ^ JSR 311: JAX-RS: The JavaTM API for RESTful Web Services.
4. ^ Web Services Description Language (WSDL) Version 2.0 Part 2: Adjuncts.

See also

External links

Rest may refer to:
  • To relax or take time off; see leisure
  • Rest (music), a pause in a piece of music
  • Rest (physics), the relation between two observers
  • Rest (fitness), a period of relative inactivity to allow recovery and growth

..... Click the link for more information.
Software development process
Activities and steps
Requirements | Architecture | Implementation | Testing | Deployment
Models
Agile | Cleanroom | Iterative | RAD | RUP | Spiral | Waterfall | XP
Supporting disciplines
..... Click the link for more information.
Hypermedia is a term created by Ted Nelson, and used in his 1965 article Complex information processing: a file structure for the complex, the changing and the indeterminate .
..... Click the link for more information.
World Wide Web (commonly shortened to the Web) is a system of interlinked, hypertext documents accessed via the Internet. With a web browser, a user views web pages that may contain text, images, videos, and other multimedia and navigates between them using hyperlinks.
..... Click the link for more information.
cleanup to meet Wikipedia's quality standards.

Please help [ improve the article] or discuss these issues on the talk page.
..... Click the link for more information.
Roy T. Fielding (born 1965) is one of the principal authors of the HTTP specification and a frequently-cited authority on computer network architecture.

Fielding was born in Laguna Beach, California, U.S.A.
..... Click the link for more information.
20th century - 21st century
1970s  1980s  1990s  - 2000s -  2010s  2020s  2030s
1997 1998 1999 - 2000 - 2001 2002 2003

2000 by topic:
News by month
Jan - Feb - Mar - Apr - May - Jun
..... Click the link for more information.
Hypertext Transfer Protocol (HTTP) is a communications protocol used to transfer or convey information on the World Wide Web. Its original purpose was to provide a way to publish and retrieve HTML hypertext pages.
..... Click the link for more information.
In computing, network architecture is the design of a computer network.

In telecommunication, the term network architecture has the following meanings:

..... Click the link for more information.
Simple Object Access Protocol, and lately also Service Oriented Architecture Protocol, but is now simply SOAP. The original acronym was dropped with Version 1.2 of the standard, which became a W3C Recommendation on June 24 2003, as it was considered to be misleading.
..... Click the link for more information.
HTTP cookies, sometimes known as web cookies or just cookies, are parcels of text sent by a server to a web browser and then sent back unchanged by the browser each time it accesses that server.
..... Click the link for more information.
Remote procedure call (RPC) is a technology that allows a computer program to cause a subroutine or procedure to execute in another address space (commonly on another computer on a shared network) without the programmer explicitly coding the details for this remote
..... Click the link for more information.
In Technology Evangelism, a RESTafarian is an individual that espouses the benefits of simplified computer-to-computer interfaces embodied by the REST Design Pattern.

The REST interface is usually used instead of more complex computer-to-computer standards such as SOAP.
..... Click the link for more information.
In computing, code on demand is a general term for any technology that sends executable software programs from a server computer to a client computer upon request from the client's software (e.g., browser).

Code on demand is a specific use of mobile code.
..... Click the link for more information.
The concept of Resource is primitive in the Web architecture, and is used in the definition of its fundamental elements. The term was first introduced to refer to targets of Uniform Resource Locators (URLs), but its definition has been further extended to include the referent of
..... Click the link for more information.
Uniform Resource Identifier (URI), is a compact string of characters used to identify or name a resource. The main purpose of this identification is to enable interaction with representations of the resource over a network, typically the World Wide Web, using specific
..... Click the link for more information.
circle is the set of all points in a plane at a fixed distance, called the radius, from a given point, the centre.

Circles are simple closed curves which divide the plane into an interior and exterior.
..... Click the link for more information.
Scalable Vector Graphics

File extension: .svg, .svgz
MIME type: image/svg+xml[1]
Developed by: World Wide Web Consortium
Type of format: vector image format
Extended from: XML


..... Click the link for more information.
Comma-separated values

File extension: .csv
MIME type: text/csv
text/comma-separated-values (deprecated)
The comma-separated values (or CSV; also known as a comma-separated list or
..... Click the link for more information.
A client is an application or system that accesses a (remote) service on another computer system known as a server by way of a network. The term was first applied to devices that were not capable of running their own stand-alone programs, but could interact with remote computers
..... Click the link for more information.
Server Computer

The inside/front of a server computer

Connects to:
  • Internet via one of

..... Click the link for more information.
cache (IPA:/kæʃ/, like "catch" [1]) is a collection of data duplicating original values stored elsewhere or computed earlier, where the original data is expensive to fetch (due to longer access time) or to
..... Click the link for more information.
A tunneling protocol is a network protocol which encapsulates a payload protocol, acting as a payload protocol. Reasons to tunnel include carrying a payload over an incompatible delivery network, or to provide a secure path through an untrusted network.
..... Click the link for more information.
Web caching is the caching of web documents (e.g., HTML pages, images) in order to reduce bandwidth usage, server load, and perceived lag. A web cache stores copies of documents passing through it; subsequent requests may be satisfied from the cache if certain conditions are met.
..... Click the link for more information.
WebDAV, an abbreviation that stands for Web-based Distributed Authoring and Versioning, refers to the set of extensions to the Hypertext Transfer Protocol (HTTP) which allows users to collaboratively edit and manage files on remote World Wide Web servers.
..... Click the link for more information.
Hypertext Transfer Protocol (HTTP) is a communications protocol used to transfer or convey information on the World Wide Web. Its original purpose was to provide a way to publish and retrieve HTML hypertext pages.
..... Click the link for more information.
HTML (Hypertext Markup Language)

File extension: .html, .htm
MIME type: text/html
Type code: TEXT
..... Click the link for more information.
On the Internet, the Domain Name System (DNS) associates various sorts of information with so-called domain names; most importantly, it serves as the "phone book" for the Internet by translating human-readable computer hostnames, e.g. en.wikipedia.
..... Click the link for more information.
In computing, code on demand is a general term for any technology that sends executable software programs from a server computer to a client computer upon request from the client's software (e.g., browser).

Code on demand is a specific use of mobile code.
..... Click the link for more information.
Uniform Resource Identifier (URI), is a compact string of characters used to identify or name a resource. The main purpose of this identification is to enable interaction with representations of the resource over a network, typically the World Wide Web, using specific
..... Click the link for more information.


This article is copied from an article on Wikipedia.org - the free encyclopedia created and edited by online user community. The text was not checked or edited by anyone on our staff. Although the vast majority of the wikipedia encyclopedia articles provide accurate and timely information please do not assume the accuracy of any particular article. This article is distributed under the terms of GNU Free Documentation License.
Herod_Archelaus


page counter