This document was uploaded by user and they confirmed that they have the permission to share
it. If you are author or own the copyright of this book, please report to us by using this DMCA
report form. Report DMCA
Overview
Download & View Rest And Ajax Reconciled as PDF for free.
REST and AJAX reconciled Lars Trieloff at AJAX World East 2008
What is REST?
What is REST? • Buzzword
What is REST? • Buzzword • Alternative to SOAP
What is REST? • Buzzword • Alternative to SOAP • Representational State Transfer
What is REST? • Buzzword • Alternative to SOAP • Representational State Transfer • Architecture of the World Wide Web
What is REST? • Buzzword • Alternative to SOAP • Representational State Transfer • Architecture of the World Wide Web • Architecture for Scalable Network Applications
How do we start? • Introduction • Core Concepts • REST Clients • AJAX REST Clients • REST Frameworks • REST Frameworks for AJAX
Things are Resources Resource
Resources can be items of information (a blog entry) or or informational descriptions of real things (a blog author)
Resources have URIs Resource
URI
Uniform Resource Identifier are unique ids for resources, just like ISBN for a book or a driver’s license for a person
Resources have Representations
Representation
Resource
Representation
URI
Representations can have different formats (HTML, XML, JSON) or show different aspects of a resource.
Representations have URLs URL Representation
URL Resource
Representation
URI
Uniform Resource Locators describe how to get to a representation of a resource, they include protocol, hostname, path and extra information
Clients interact via Verbs GET
URL Representation
POST
PUT
Resource
URL Representation
URI
Uniform Resource Locators describe how to get to a representation of a resource, they include protocol, hostname, path and extra information
DELETE
GET is for reading GET
Representation
Representation
Resource
Resource
Before
After
GET is a “safe” method. There are no side-effects, and the requested resource stays unmodified.
PUT is for replacing PUT
Representation
Representation
Resource
Resource
Before
After
PUT is a “idempotent” method. Issuing the same PUT request multiple times yields the same result.
DELETE is for deleting DELETE
Representation
Resource
Before
After
DELETE is also “idempotent”. Deleting a resource twice yields the same result - the resource is gone.
POST is for action POST
Representation
Representation
Representation
Resource
Resource
Resource
Before
After
POST is neither safe nor idempotent. It is used for updating, creating and executing resources.
So what? • There are unlimited resources • Every resource can be addressed • There are only four verbs • Resources have an uniform interface This makes it easy to write clients for existing REST applications and makes it easy to expose a RESTful interface to an application.
How do we go on? • Introduction • Core Concepts • REST Clients • AJAX REST Clients • REST Frameworks • REST Frameworks for AJAX
What are REST Clients • Libwww • Microsoft Internet Explorer • Apache Commons HTTPClient • Mozilla Firefox • Python httplib • Apple Safari • Ruby Net::HTTP • Opera
HTTP Client Libraries
+ Desktop Applications + +Server-side mashups - Not in the web browser Full HTTP Support
Web Browsers as HTTP Clients
+ +Everywhere installed - Weak HTTP Support - Web Forms 1.0 - Browser Bugs No client needed
Web Forms 1.0
Web Forms 1.0 I o d w But ho change rmlly oa e d e d o c n h e l r u t m r o f w f w w x / o n ) e applicatio " = e p c y t c n r e u o res ? m r o f e"> l t i t " = e m a n " t x e t " = e p y t e b a l / < y r t n E > " t x e t " = r o f