Helping Things to REST

1,079 views
1,009 views

Published on

Helping Things to REST

Published in: Technology, Design
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,079
On SlideShare
0
From Embeds
0
Number of Embeds
21
Actions
Shares
0
Downloads
29
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Helping Things to REST

  1. 1. Helping Things to « REST » Web of Things Presentation, part II Dominique Guinard [email_address] Institute for Pervasive Computing, ETH Zurich Lenzerheide, January 2009
  2. 2. Service Oriented Architectures: The WS-* World [ WS Standards, http://www.innoq.com/soa]
  3. 3. Resource Oriented Architectures: The REST World <ul><li>Resources. </li></ul><ul><li>Their names (URIs). </li></ul><ul><li>Their representations (JSON, XHTML) </li></ul><ul><li>Links between them. </li></ul><ul><li>A uniform interface (HTTP). </li></ul>XHTML HTTP URI
  4. 4. Comparing the Two Worlds <ul><li>SOA WS-* Approach </li></ul><ul><li>HTTP as transporter. </li></ul><ul><li>The comp-comp interface is a WSDL. </li></ul><ul><li>User Interface? </li></ul><ul><li>Testing: stub generation from a WSDL and lots of SOAP messages. </li></ul><ul><li>SOA loves XML. </li></ul><ul><li>An App Server everywhere. </li></ul><ul><li>Heavy. </li></ul><ul><li>ROA REST Approach </li></ul><ul><li>HTTP as service platform! </li></ul><ul><li>The comp-comp interface is the URL. </li></ul><ul><li>The UI is the URL/browser. </li></ul><ul><li>Testing by typing a URL in your browser (doable?) </li></ul><ul><li>ROA loves JSON. </li></ul><ul><li>A Web Server everywhere . </li></ul><ul><li>Less heavy. </li></ul>
  5. 5. RESTifying the Spots
  6. 6. 1. Resource Design <ul><li>Root: http://webofthings.net/ </li></ul><ul><li>Resources: </li></ul><ul><ul><li>Spots: http://webofthings.net/spots </li></ul></ul><ul><ul><li>Spot 2: http://webofthings.net/spots/2 </li></ul></ul><ul><ul><li>Light Sensor: http://webofthings.net/spots/2/sensors/light </li></ul></ul><ul><ul><li>Led Actuator: http://webofthings.net/spots/2/actuators/led/ </li></ul></ul>
  7. 7. 2. Representation Design <ul><li>XHTML as default, ideal for browsing: </li></ul><ul><ul><li>http://webofthings.net/spots </li></ul></ul><ul><li>JSON, ideal for parsing: </li></ul><ul><ul><li>http://webofthings.net/spots.json </li></ul></ul><ul><li>XML, ideal for integration </li></ul><ul><ul><li>http://webofthings.net/spots.xml </li></ul></ul>
  8. 8. 3. Uniform Interface [ HTTP: http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol]
  9. 9. 3. Uniform Interface <ul><li>HTTP Verbs: What do you wanna do? </li></ul><ul><ul><li>GET: retrieve the representation of a resource. </li></ul></ul><ul><ul><li>PUT: create or update a resource. </li></ul></ul><ul><ul><li>DELETE: remove a resource. </li></ul></ul><ul><ul><li>POST: create a subordinate (or custom: RPC!) </li></ul></ul><ul><li>HTTP Headers: What are you sending me? </li></ul><ul><ul><li>Metadata: </li></ul></ul><ul><ul><ul><li>Content type: application/json, text/html, etc. </li></ul></ul></ul><ul><ul><li>Status: </li></ul></ul><ul><ul><ul><li>200 OK, 201 Create, 400 Bad Request, 401 Unauthorized </li></ul></ul></ul><ul><li>HTTP Body: The meat (or let’s say the carrots): </li></ul><ul><ul><li>The content in its representation. </li></ul></ul>
  10. 10. Thoughts and Buzz Use your brains! > don’t design-by-buzzword > don’t believe everything you read > always keep in mind that change is inevitable [ Fielding, Roy. “ A little REST and Relaxation” Jazoon 2007] Cache Authenticate Encrypt Link Share Reuse Stateless Lightweight IPv6 Lowpan Mobile Replicate Cloud Scale
  11. 11. <ul><li>www.webofthings.net </li></ul>

×