Documente Academic
Documente Profesional
Documente Cultură
What is REST?
Network Architectural style Coined by Roy Fielding in his Ph.D. dissertation in 2000 Overview:
Resources are defined and addressed Transmits domain-specific data over HTTP Does not have any SOAP messaging layer or HTTP cookies
Resources
Web is comprised of resources, e.g. BMW defines Z4 Coup as a resource Users access it with the URL: http://www.bmw.com/en/newvehicles/Z4/Coupe A representation is returned, e.g.Z4Coupe.html This representation puts the client application in a state Accessing another hyperlink, e.g. accessories transfers the client application into another state
A user session
HTTP GET request
Response (HTML/XML doc)
List of Items
/00345
Web Server
HTTP response
Item Data
HTTP POST
PO (HTML/XML)
PO.xml
PO HTTP response
URL to submitted PO
Characteristics
Traversing links pulls representations (pull-based client-server interaction) Each request must be self-sufficient, not taking advantage of any store resource (stateless) Capability of storing responses to frequent requests (cacheable or non-cacheable) Resources are access via (HTTP) GET, POST, PUT, DELETE (uniform interface) Every resource is named using an URL (named resources) Resources are interconnected using URLs (interconnected resource representations) Intermediate components, e.g. proxy servers, gateways, firewalls, etc. can be inserted between clients and resources for performance, security (layered components)
4. 5. 6.
Connect resources through hyperlinks Specify the format of the response using a schema, e.g. DTD, W3C schema, RelaxNG (also take care of POST or PUT services) Describe how your services should be invoked (in a WSDL or HTML document)
Stateless Constraint
Single request reveals everything Easier to recover from failures Server does not commit resources to each request May degrade network performance when having large requests
Caching constraint
Eliminates interactions Clients have the right to reuse cacheable data May degrade reliability due to stale data
- Code-on-demand (inactive code is executed on the client when the user requests it)
Extensibility Performance
Yes, through links
Security
REST
Interconnections (hyperlinks)
SOAP RPC
References
Main reference:
Roger L. Costello, Building the Web Services the REST way, http://www.xfront.com/REST-Web-Services.html
Additional references:
Paul Prescod, Second Generation Web Services, http://webservices.xml.com/pub/a/ws/2002/02/06/rest.html?page=1 Wikipedia article, http://en.wikipedia.org/wiki/Representational_State_Transfer Henning Niss, REST for Web Services http://www.itu.dk/courses/IWSJ/E2005/slides/lecture7.pdf Hao He, Implementing REST Web Services: Best Practices and Guidelines http://www.xml.com/pub/a/2004/08/11/rest.html?page=1 Ryan Tamayko, How I explained REST to my wife http://tomayko.com/articles/2004/12/12/rest-to-my-wife