Presentation is loading. Please wait.

Presentation is loading. Please wait.

REST (Representational State Transfer) Neil Ernst Some material from Costello and Kehoe, John Cowan, Roy Fielding, Paul Prescod.

Similar presentations


Presentation on theme: "REST (Representational State Transfer) Neil Ernst Some material from Costello and Kehoe, John Cowan, Roy Fielding, Paul Prescod."— Presentation transcript:

1 REST (Representational State Transfer) Neil Ernst Some material from Costello and Kehoe, John Cowan, Roy Fielding, Paul Prescod

2 … the web is an existence proof of a massively scalable distributed system that works really well, and we can take ideas from that to build integrated systems more easily. – Martin Fowler Why REST? http://martinfowler.com/articles/richardsonMat urityModel.html

3 The HTTP API HTTP provides a simple set of operations. –GET = retrieve a resource (idempotent) –POST = store a new/updated resource –PUT = store a resource at a URI (idempotent) –DELETE = remove this resource (idempotent) The HTTP API can implement CRUD - (Create, Retrieve, Update, and Delete) http://www.w3.org/Protocols/rfc2616/rfc2616- sec9.html

4 Idempotence An operation that can be applied multiple times without changing the result after the first application –E.g. floor(x) where x is a real number –Subtract average from a list of numbers PUT/GET/DEL operations are by definition idempotent E.g. GET http://www.cnn.com/index.htm does not change the resource.http://www.cnn.com

5 Nouns and verbs Two choices: –RPC – model the API using verbs – the operations E.g. setCustomer(c_id, name, address) Must define the data elements as well –RESTful model the API nouns – the data representation and state – and keep ops simple Eg. PUT issue/{id} Leverage the scalability of the HTTP infrastructure –Caching, third-party libraries Simplify one part of the API

6 Copyright 2005 John Cowan under GPL Two views of POST POST lets you pass a whole lot of parameters and get something back, bypassing caches. POST lets you create new resources that are related to old ones. The second is the REST attitude

7 What is REST? " REST " was coined by Roy Fielding in his Ph.D. dissertation [1] to describe an arch. style for implementing networked systems. [1] http://www.ics.uci.edu/~fielding/pubs/dissertation/top.htm

8 Copyright 2005 John Cowan under GPL REST principles 1.Resources are identified by uniform resource identifiers (URIs) 2.Resources are manipulated through their representations 3.Messages are self-descriptive and stateless 4.Multiple representations are accepted or sent 5.Hypertext As The Engine Of Application State (HATEOAS)

9 REST design criteria Support a distributed web of hypermedia documents numbering in the billions. Layered separation to support independent evolution Replication and caching to support scaling. Universal, limited set of operations to support extensibility. Stateless to support independent processing.

10 Why is it called "Representational State Transfer? " Resource Client http://www.boeing.com/aircraft/747 Boeing747.html The Client references a Web resource using a URL. A representation of the resource is returned (in this case as an HTML document). The representation (e.g., Boeing747.html) places the client in a new state. When the client selects a hyperlink in Boeing747.html, it accesses another resource. The new representation places the client application into yet another state. Thus, the client application transfers state with each resource representation. Fuel requirements Maintenance schedule...

11 Representational State Transfer "Representational State Transfer is intended to evoke an image of how a well-designed Web application behaves: a network of web pages (a virtual state- machine), where the user progresses through an application by selecting links (state transitions), resulting in the next page (representing the next state of the application) being transferred to the user and rendered for their use." - Roy Fielding


Download ppt "REST (Representational State Transfer) Neil Ernst Some material from Costello and Kehoe, John Cowan, Roy Fielding, Paul Prescod."

Similar presentations


Ads by Google