RESTful http_patterns_antipatterns

3,324

Published on

Presentation at prioconference 2010 about RESTful HTTP and common misuses of HTTP.

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

No Downloads
Views
Total Views
3,324
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
43
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

RESTful http_patterns_antipatterns

  1. 1. RESTful HTTP Patterns and Anti-Patterns Jan Algermissen prioconference 2010, Nürnberg
  2. 2. Jan Algermissen “Applying the Web to Enterprise IT” @algermissen algermissen@acm.org http://www.nordsc.com/blog NORD Software Consulting http://www.nordsc.com/
  3. 3. REST
  4. 4. REpresentational State Transfer
  5. 5. An architectural style for network-based software architectures
  6. 6. HTTP
  7. 7. RESTful HTTP The Web used correctly
  8. 8. 1991 HTTP 0.9 HTTP 1.1 HTTP 1.0 Start HTTP 1.1bis 2000 REST 20071996
  9. 9. User Use Case Application Application
  10. 10. Connectors Components User Use Case Data Application
  11. 11. Architectural Elements Components Connectors Data
  12. 12. Architectural Style A set of constraints on architectural elements. To achieve certain system properties.
  13. 13. Connectors Components User Use Case Application Monolithic
  14. 14. User Use Case Application Components Connectors Unix Command Line
  15. 15. Network-Based (ODBC)User Use Case Application ComponentsConnector
  16. 16. User Use Case Application Connector Components Network-Based (ODBC)
  17. 17. Application User Agent Component Server ComponentIntermediary Component Connectors Network-Based (HTTP)User Use Case
  18. 18. User Use Case Application User Agent Component Server ComponentIntermediary Component Connectors Administrative Domain Network-Based (HTTP)
  19. 19. Network Trust Federated Change Complexity Unpredictable Use Evolvability Issues of network-based, decentralized systems Performance Simplicity Scalability Visibility
  20. 20. Evolvability Performance Simplicity Scalability Visibility Properties of Key Interest
  21. 21. Manipulation of resources through representations Self-descriptive messages Hypermedia as the engine of application state REST Four core constraintsIdentification of resources
  22. 22. Identification of resources Manipulation of resources through representations Self-descriptive messages Hypermedia as the engine of application state REST
  23. 23. http://sample.org/customers/5561 http://sample.org/customers/5561/address http://sample.org/customers/high-potential http://sample.org/orders/?status=payment-pending http://sample.org/order-processor http://weather.com/london/forecast ftp://sample.org/ mailto:incidents@support.mycorp.com geo:37.0625,-95.677068
  24. 24. Identification of resources Manipulation of resources through representations Self-descriptive messages Hypermedia as the engine of application state REST
  25. 25. getCatalog getProductDetails findProduct placeOrder changeOrder cancelOrder notifyOfPayment showOrdersByMonth listOrdersPendingPayment RemoveAccount updateOrderState
  26. 26. getCatalog getProductDetails findProduct placeOrder changeOrder cancelOrder notifyOfPayment showOrdersByMonth listOrdersPendingPayment RemoveAccount updateOrderState GET DELETE PUT POST
  27. 27. GET /catalog GET /products/667 GET /products?search=lego POST /orders/ PUT /orders/42 DELETE /orders/42 POST /payment-notifications/ GET /orders/2009/?month=June GET /orders/payment-pending DELETE /accounts/bob PUT /orders/42/state GET DELETE PUT POST
  28. 28. Identification of resources Manipulation of resources through representations Self-descriptive messages Hypermedia as the engine of application state REST
  29. 29. GET /srv/orders/6651 HTTP/1.1 200 Ok Date: Mon, 18 Oct 2010 21:40:29 GMT Server: Apache/2 ETag: "12345" Cache-Control: public, max-age=3600 Content-Type: application/vnd.oasis.ubl <order> <items> ... </items> <total currency=”USD” amount=”52.77”/> </order>
  30. 30. Self-Descriptive Massages Uniform Interface Stateless Server
  31. 31. Identification of resources Manipulation of resources through representations Self-descriptive messages Hypermedia as the engine of application state REST
  32. 32. GET /order-form.html 200 Ok Content-Type: text/html <html><body> <form action=”/orders” method=”POST”> <img src=”/img/dish-A.jpg”/> <img src=”/img/dish-B.jpg”/> <input type=”text” name=”dish”/> <input type=”submit” value=”Order Now”/> </form> </body></html>
  33. 33. GET /srv/catalog 200 Ok Content-Type: application/vnd.oasis.ubl Link: </srv/about>;rel=”service” <catalog href=”/srv/catalog”> <order-processor href=”/srv/orders” accept=”application/vnd.oasis.ubl”/> <item href=”/srv/products/2213-21”> <name> .... </name> </item> <item href=”/srv/products/2213-22”> <name> .... </name> </item> </catalog>
  34. 34. Example System
  35. 35. CATALOG
  36. 36. UnRESTful HTTP (Anti-Patterns)
  37. 37. RPC URI-Tunneling w/GET GET /srv/?action=getCatalog GET /srv/?action=getDetails&productID=2213-21 GET /srv/?action=placeOrder&itemIDs=23,455,12 GET /srv/?action=changeOrder&orderId=42&newiItemId=25 GET /srv/?action=cancelOrder&orderId=42 GET /srv/?action=notifyPayment&orderId=42 GET /srv/?action=getReport&year=2009&week=34
  38. 38. RPC URI-Tunneling POST /srv/?action=getCatalog POST /srv/?action=getDetails&productID=2213-21 POST /srv/?action=placeOrder&itemIDs=23,455,12 POST /srv/?action=changeOrder&orderId=42&newiItemId=25 POST /srv/?action=cancelOrder&orderId=42 POST /srv/?action=notifyPayment&orderId=42 POST /srv/?action=getReport&year=2009&week=34
  39. 39. Performance Scalability Simplicity Visibility Evolvability POST /srv/?action=getDetails&productID=2213-21 POST /srv/?action=changeOrder&orderId=42&newiItemId=25 POST /srv/?action=notifyPayment&orderId=42
  40. 40. HTTP-Based Type I GET /srv/catalog GET /srv/products/2213-21 POST /srv/orders PUT /srv/orders/42 DELETE /srv/orders/42 POST /srv/payment-notifications GET /srv/reports/2009/34 Service Description: •Fixed list of URIs •WADL or equiv. •Service specific XML • Fixed, no content negotiation
  41. 41. GET /srv/products/2213-21 200 Ok Content-Type: application/xml <item xmlns=”...”> <name>Lego Tower Bridge</name> <description> ... </description> <inStock>26</inStock> <item>
  42. 42. Performance Scalability Simplicity Visibility Evolvability GET /srv/catalog GET /srv/products/2213-21 POST /srv/orders PUT /srv/orders/42 DELETE /srv/orders/42 POST /srv/payment-notifications
  43. 43. HTTP-Based Type II GET /srv/catalog GET /srv/products/2213-21 POST /srv/orders PUT /srv/orders/42 DELETE /srv/orders/42 POST /srv/payment-notifications GET /srv/reports/2009/34 Service Description: •Fixed list of URIs •WADL or equiv. •Use of ‘standard’ media types • Fixed, no content negotiation
  44. 44. GET /srv/products/2213-21 200 Ok Content-Type: application/vnd.oasis.ubl <item xmlns=”...”> <name>Lego Tower Bridge</name> <description> ... </description> <inStock>26</inStock> <item>
  45. 45. Performance Scalability Simplicity Visibility Evolvability GET /srv/catalog GET /srv/products/2213-21 POST /srv/orders PUT /srv/orders/42 DELETE /srv/orders/42 POST /srv/payment-notifications
  46. 46. RESTful HTTP
  47. 47. REST GET /srv/catalog application/vnd.oasis.ubl
  48. 48. GET /srv/catalog 200 Ok Content-Type: application/vnd.oasis.ubl Link: </srv/about>;rel=”service” <catalog href=”/srv/catalog”> <order-processor href=”/srv/orders” accept=”application/vnd.oasis.ubl”/> <item href=”/srv/products/2213-21”> <name> .... </name> </item> <item href=”/srv/products/2213-22”> <name> .... </name> </item> </catalog>
  49. 49. GET /srv/about 200 Ok Content-Type: application/atomsvc+xml <service> <workspace> <collection href=” /srv/payment-notifications”/> <category term=”oms:remittance-advice”/> <accept>application/vnd.oasis.ubl</accept> </collection> <collection href=”/srv/reports/”/> <category term=”oms:report”/> <category term=”oms:weekly”/> <accept/> </collection> </workspace> </service>
  50. 50. Performance Scalability Simplicity Visibility Evolvability GET /srv/catalog Media Types (service independent) Find transitions at runtime
  51. 51. Take Aways •Network-based, decentralized creates issues. •Constrain architectural elements to deal with issues. •RPC URI tunneling is bad in all forms at no benefit whatsoever. •At least use HTTP Type I. •HTTP Type I might be just what you need (but its not REST).
  52. 52. The Web and Enterprise IT have a very similar problem space!
  53. 53. Thank you!
  54. 54. 1991 HTTP 0.9 HTTP 1.1 HTTP 1.0 Start HTTP 1.1bis 20092000 “SOA Is Dead” REST REST vs. SOAP war SOAP 1.1 SOAP 1.2 20071996
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×