1 / 88

REST & .NET

REST & .NET. James Crisp .NET Practice Lead ThoughtWorks Australia. James Crisp. The Web. *-ilities. Scalability. Recoverability & Reliability. Security. Discoverability. How to bring to Web services?. Tunneling. RPC URLs POX SOAP & WS-*. RE presentational S tate

Télécharger la présentation

REST & .NET

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. REST & .NET James Crisp .NET Practice Lead ThoughtWorks Australia

  2. James Crisp

  3. The Web

  4. *-ilities

  5. Scalability

  6. Recoverability & Reliability

  7. Security

  8. Discoverability

  9. How to bring to Web services?

  10. Tunneling RPC URLs POX SOAP & WS-*

  11. REpresentational State Transfer

  12. “REST contributes ... the rationale behind the modern Web's software architecture...” -- Roy Fielding

  13. Resources e.g. Person, Car, Post

  14. Representations <person> <name>Bill Gates</name> <gender>m</gender> </person>

  15. Addressability http://mysite.com/people/joe_citizen http://mysite.com/people/joe_citizen/friends

  16. Uniform Interface

  17. GET POST HEAD PUT DELETE OPTIONS Support

  18. GET GET /people/joe_citizen HTTP/1.1 Host: mysite.com Accept: application/xml

  19. Response 200 OK Content-Type: application/xml Last-Modified: 2008-1-1 15:00.. <person> <name>Joe Citizen</name> <age>42</age> <gender>m</gender> </person>

  20. HEAD HEAD /people/joe_citizen HTTP/1.1 Host: mysite.com 200 OK Content-Type: application/xml Last-Modified: 2008-1-1 15:00.. ETag: a32daf15-b33da2a4d Response

  21. POST POST /people HTTP/1.1 Content-Type: text/xml Host: mysite.com .... <person> <name>Tina Jones</name> <age>25</age> <gender>F</gender> </person>

  22. Response 201 CREATED Location: /people/tina_jones (optionally with body)

  23. PUT PUT /people/tina_jones HTTP/1.1 Content-Type: text/xml Host: mysite.com .... <person> <name>Tina Jones</name> <age>24</age> <gender>F</gender> </person>

  24. Response 200 OK Location: /people/tina_jones (optionally with body)

  25. DELETE DELETE /people/joe_citizen HTTP/1.1 Host: mysite.com 200 OK Content-Type: application/xml <admin:personDeleted> joe_citizen </admin:personDeleted> Response

  26. OPTIONS OPTIONS /people HTTP/1.1 Host: mysite.com Response 200 OK Allowed: GET,HEAD,POST

  27. Status Codes

  28. 2xx = All good 200 – OK 201 – Created

  29. 3xx = Redirect 301 – Moved permanently 307 – Temporary redirect304 – Not modified (ie, see cache)

  30. 4xx = Client error 400 – Bad request 401 – Unauthorized 403 – Forbidden 405 – Method not allowed 409 – Conflict

  31. 5xx = Server error 500 – Internal server error

  32. Headers

  33. Content-Type: text/html application/xml image/jpeg ....

  34. WWW-Authenticate: Authorization:

  35. Last-Modified: If-Modified-Since: ETag: If-None-Match:

  36. Location:

  37. Describe your services?

  38. URI Templates http://s3.amazon.com/{bucket-name}/{object-name} http://mysite.com/users/{user-name}/photos http://google.com/search?q={search-query}

  39. Start URL + Links https://bank.com/accounts/345095 <account> <name>Tina Jones</name> <link rel="history" href="/tjones/account_history"> <link rel="close" verb="delete" href="/tjones"> </account>

  40. Microformats <account> <name>Tina Jones</name> <link rel="transaction-search" href="account_history? from={date-from}& to={date-to}"> </account>

  41. State Management http://google.com Searching Search google.com/search?q=rest Searched Next Page google.com/search?q=rest&start=10 More Results

  42. Data Format?

  43. XHTML <h1>Accounts</h1> <ul> <li> <a rel="account_details" href="/tjones">Tina Jones</a> </li> <li> .....

  44. JSON { "account_name": "Tina Jones", "links": {"history": "/tjones/history"} }

  45. <XML></XML>

  46. Framework

More Related