REST
1 History
- Socket
- Protocols: SMTP, HTTP.
- RPC: XML-RPC, CORBA, SOAP.
- REST
Vinosky's history of RPC [5]
1.1 Protocols
- A highly structured language.
- HTTP: POST PUT GET DELETE
- Need to write parser each time.
1.2 RPC
- Idea: programmer types
calculate("John", 10,
now)
and it runs elsewhere.
- Easy for the programmer.
- Requires middleware: installation and maintenance.
- If they change, I re-compile.
- Very tight coupling.
2 REST
- Representational State Transfer
2.1 REST Main Ideas
- The server holds resources.
- Clients can get representations of these resources.
- URI [6]
identifies each resource.
- All interesting data in app should be addressable by an
URI.
- App is stateless.
2.2 Example:Delicious
2.3 HTTP for REST
- Delicious only uses GET.
- Good REST calls for:
- GET: retrieve a resource.
- PUT: modify an existing resource.
- DELETE: delete resource.
- POST: create subordinate resource.
- GET is safe: does not change anything in server.
- GET, PUT, DELETE are idempotent: can be safely done many times.
3 JSONP
- Problem: I want to call REST service on some other
server, but XHR requests can only go to my server.
- Solution: write JavaScript that creates
script
elements (JavaScript on demand). Only
works if he return JSON.
- JSONP [8]
adds a
callback
attribute.
- Example [9] using delicious' feeds [10].
URLs
- José M. Vidal, http://jmvidal.cse.sc.edu
- http://jmvidal.cse.sc.edu/talks/rest/, http://jmvidal.cse.sc.edu/talks/rest/
- wikipedia:REST, http://en.wikipedia.org/wiki/Representational_State_Transfer
- RESTful Web Services, http://www.amazon.com/exec/obidos/ASIN/0596529260/ref=nosim/multiagentcom
- Vinosky's history of RPC, http://qconlondon.com/london-2009/file?path=/qcon-london-2009/slides/SteveVinoski_RPCAndItsOffspringConvenientYetFundamentallyFlawed.pdf
- wikipedia:Uniform_Resource_Identifier, http://www.wikipedia.org/wiki/Uniform_Resource_Identifier
- Delicious API, http://delicious.com/help/api
- JSONP, http://bob.pythonmac.org/archives/2005/12/05/remote-json-jsonp/
- Example, http://jmvidal.cse.sc.edu/talks/rest/delicious.html
- delicious' feeds, http://delicious.com/help/feeds
This talk available at http://jmvidal.cse.sc.edu/talks/rest/
Copyright © 2009 José M. Vidal
.
All rights reserved.
25 March 2009, 03:03PM