REST(Representational State Transfer)            Omkar J. Kulkarni
http://www.boeing.com/aircraft/747          Client                                               Resource                 ...
" REST " was coined by Roy Fielding  in his Ph.D. dissertation [1] to describe a design   pattern for implementing network...
 REST is a design pattern. It is a certain approach to creating Web Services. REST is a lightweight alternative to mech...
 While REST is not a standard, it does use standards:1. HTTP2. URL3. XML/HTML/GIF/JPEG/etc. (Resource   Representations)4...
 Client-Server: a pull-based interaction style: consuming  components pull representations. Stateless: each request from...
REST"Representation State Transfer"     WebApp                          Cache                        (Resource            ...
• The REST design pattern is best explained with an  example.• I will present an example of a company deploying  three Web...
 Suppose that an airline wants to create a telephone  reservation system for customers to call in and make  flight reserv...
The airline provides a single telephone number.    Upon entry into the system a customer encounters an    automated messag...
 The airline provides several telephone numbers - one  number for premier members, a different number for  frequent flyer...
 Suppose now the airline (kings-air.com) wants to provide a  Web reservation service for customers to make flight  reserv...
 The airline provides a single URL. The Web service  is responsible for examining incoming client  requests to determine ...
 There is currently no industry accepted practice (rules)  for expressing priorities, so rules would need to be  made. Th...
 Axiom 0: all resources on the Web must be uniquely identified with a URI.               URL1                           r...
The airline provides several URLs - one URL forpremier members, a different URL for frequentflyers, and still another for ...
 The different URLs are discoverable by search engines and    UDDI registries.   Its easy to understand what each servic...
 We have looked at a reservation service. We have seen a telephone-based version and a Web-  based version of the reserv...
This Isnt the                                                                  Premier                                    ...
This is the                                                     Premier                                1-800-Premier      ...
client                                                    Premier  Premier Members                                  Custom...
Premier                       http://www.kings-air/reservations/premier     Member          client                        ...
Resources             URLs                         Simple OperationsWe discussed how Resources and URLs are fundamental to...
Summary of the       REST Design Pattern Create a resource for every service. Uniquely identify each resource with a log...
 HTTP provides a simple set of operations. Amazingly, all Web exchanges are done using this simple HTTP API:     GET = "...
WS-        listEntries()             addEntry()      collection              getEntry()     service           deleteEntry...
1. A SOAP (Simple Object Access Protocol) service (WS-) has a single   endpoint that handles all the operations – therefo...
What are the advantages of using Soft Layers RESTAPI?1. Direct client to server communication is the biggest   advantage o...
What are the disadvantages of using a REST API?1. REST requests must contain all   information, including authentication, ...
• Resources and Resource Identifiers   • Uniform Interface (GET, PUT, POST, DELETE)   • Resource Oriented   • Simple and s...
Rest Data Element (cont.)• safe : no side effect, The word "safe" means that if a given  HTTP method is invoked, the resou...
1.   All replies to queries are expressed as JSON objects.   2.   The general form, which all query replies share, is an a...
Rest presentation
Rest presentation
Rest presentation
Upcoming SlideShare
Loading in …5
×

Rest presentation

3,249 views

Published on

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

  • Be the first to like this

No Downloads
Views
Total views
3,249
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Rest presentation

  1. 1. REST(Representational State Transfer) Omkar J. Kulkarni
  2. 2. http://www.boeing.com/aircraft/747 Client Resource Fuel requirements Maintenance schedule ... Boeing747.html The Client references a Web resource using a URL. A representation of the resource is returned (in this case as an HTML document). The representation (e.g., Boeing747.html) places the client in a new state. When the client selects a hyperlink in Boeing747.html, it accesses another resource. The new representation places the client application into yet another state. Thus, the client application transfers state with each resource representation.
  3. 3. " REST " was coined by Roy Fielding in his Ph.D. dissertation [1] to describe a design pattern for implementing networked systems. REST is not even an architecture REST is not a standard. Why?
  4. 4.  REST is a design pattern. It is a certain approach to creating Web Services. REST is a lightweight alternative to mechanisms like RPC (Remote Procedure Calls) and Web Services (SOAP, WSDL, etc.). It relies on a stateless, client-server, cacheable communications protocol -- and in virtually all cases, the HTTP protocol is used.
  5. 5.  While REST is not a standard, it does use standards:1. HTTP2. URL3. XML/HTML/GIF/JPEG/etc. (Resource Representations)4. text/xml, text/html, image/gif, image/jpeg, etc. (MIME Types)
  6. 6.  Client-Server: a pull-based interaction style: consuming components pull representations. Stateless: each request from client to server must contain all the information necessary to understand the request, and cannot take advantage of any stored context on the server. Named resources - the system is comprised of resources which are named using a URL. Uniform interface: allresources are accessed with a generic interface (e.g., HTTP GET, POST, PUT, DELETE).
  7. 7. REST"Representation State Transfer" WebApp Cache (Resource ) Dispatche r
  8. 8. • The REST design pattern is best explained with an example.• I will present an example of a company deploying three Web services using the REST design pattern.
  9. 9.  Suppose that an airline wants to create a telephone reservation system for customers to call in and make flight reservations. The airline wants to ensure that its premier members get immediate service, its frequent flyer members get expedited service and all others get regular service. There are two main approaches to implementing the reservation service...
  10. 10. The airline provides a single telephone number. Upon entry into the system a customer encounters an automated message, "Press 1 if you are a premier member, press 2 if you are a frequent flyer, press 3 for all others." Premier Customer Representative Premier Members F.F. Answering Airline Reservations Customer Machine RepresentativeFrequent Flyer Members Regular Customer Representative Regular Members
  11. 11.  The airline provides several telephone numbers - one number for premier members, a different number for frequent flyers, and still another for regular customers. Premier 1-800-Premier Customer Representative Premier Members F.F. 1-800-Frequent Customer RepresentativeFrequent Flyer Members Regular 1-800-Reservation Customer Representative Regular Members
  12. 12.  Suppose now the airline (kings-air.com) wants to provide a Web reservation service for customers to make flight reservations through the Web. Just as with the telephone service, the airline wants to ensure that its premier members get immediate service, its frequent flyer members get expedited service, all others get regular service. There are two main approaches to implementing the Web reservation service.
  13. 13.  The airline provides a single URL. The Web service is responsible for examining incoming client requests to determine their priority and process them accordingly. client Premier Premier Members Customer Web Determine F.F. client Reservation Priority CustomerFrequent Flyer Members Service Regular Customer client Regular Members
  14. 14.  There is currently no industry accepted practice (rules) for expressing priorities, so rules would need to be made. The clients must learn the rule, and the Web service application must be written to understand the rule. This approach is based upon the incorrect assumption that a URL is "expensive" and that their use must be rationed. Load balancing is a challenge. It violates Tim Berners-Lee Web Design, Axiom 0 (see next slide).
  15. 15.  Axiom 0: all resources on the Web must be uniquely identified with a URI. URL1 resource1 URL2 resource2 URL3 resource3
  16. 16. The airline provides several URLs - one URL forpremier members, a different URL for frequentflyers, and still another for regular customers. Premier http://www.kings-air/reservations/premier Member client Reservation Premier Members Service Frequent http://www.kings-air/reservations/frequent-flyer Flyer client Reservation ServiceFrequent Flyer Members Regular http://www.kings-air/reservations/regular Member client Reservation Service Regular Members
  17. 17.  The different URLs are discoverable by search engines and UDDI registries. Its easy to understand what each service does simply by examining the URL, i.e., it exploits the Principle of Least Surprise. There is no need to introduce rules. Priorities are elevated to the level of a URL. "What you see is what you get." Its easy to implement high priority - simply assign a fast machine at the premier member URL. There is no bottleneck. There is no central point of failure. Consistent with Axiom 0.
  18. 18.  We have looked at a reservation service. We have seen a telephone-based version and a Web- based version of the reservation service. With each version we have seen two main approaches to implementing the service. Which approach is the REST design pattern and which isnt? See the following slides.
  19. 19. This Isnt the Premier Customer Representative Premier Members F.F. Answering Airline Reservation Customer Machine RepresentativeFrequent Flyer Members Regular Customer Representative Regular Members
  20. 20. This is the Premier 1-800-Premier Customer Representative Premier Members F.F. 1-800-Frequent Customer RepresentativeFrequent Flyer Members Regular 1-800-Reservation Customer Representative Regular Members
  21. 21. client Premier Premier Members Customer Reservation Determine F.F. client Web Priority CustomerFrequent Flyer Members Service Regular Customer client Regular Members
  22. 22. Premier http://www.kings-air/reservations/premier Member client Reservation Premier Members Service Frequent http://www.kings-air/reservations/frequent-flyer Flyer client ReservationFrequent Flyer Members Service Regular http://www.kings-air/reservations/regular Member client Reservation Service Regular Members
  23. 23. Resources URLs Simple OperationsWe discussed how Resources and URLs are fundamental to REST. In a follow upwe will discuss how Simple Operations are also fundamental to REST.
  24. 24. Summary of the REST Design Pattern Create a resource for every service. Uniquely identify each resource with a logical URL. All interactions between a client and a web service are done with simple operations. Most web interactions are done using HTTP and just four operations:
  25. 25.  HTTP provides a simple set of operations. Amazingly, all Web exchanges are done using this simple HTTP API:  GET = "give me some info" (Retrieve)  POST = "heres some update info" (Update)  PUT = "heres some new info" (Create)  DELETE = "delete some info" (Delete) The HTTP API is CRUD (Create, Retrieve, Update, and Delete)
  26. 26. WS- listEntries() addEntry() collection getEntry() service deleteEntry() updateEntry()RESTful listEntries() collection addEntry() getEntry() deleteEntry() entry entry entry updateEntry()
  27. 27. 1. A SOAP (Simple Object Access Protocol) service (WS-) has a single endpoint that handles all the operations – therefore it has to have an application-specific interface.2. A REST ful service has a number of resources (the collection, each entry), so the operations can be distributed onto the resources and mapped to a small uniform set of operations.
  28. 28. What are the advantages of using Soft Layers RESTAPI?1. Direct client to server communication is the biggest advantage of using REST.2. With REST you can directly link to the information that you want to display, using XLST or JavaScript to display it.3. You can also use AJAX with JSONP or script injection to dynamically update your webpage.
  29. 29. What are the disadvantages of using a REST API?1. REST requests must contain all information, including authentication, within the URL.2. This can lead to security threats somewhere down the line. Luckily, Soft Layer allows you to add any number of users to your account, and then restrict their access to specific servers/services.
  30. 30. • Resources and Resource Identifiers • Uniform Interface (GET, PUT, POST, DELETE) • Resource Oriented • Simple and simple is beautiful HTTP Method CRUD Desc. POST CREATE Create - GET RETRIEVE Retrieve Safe, Idempotent, Cacheable PUT UPDATE Update Idempotent DELETE DELETE Delete Idempotent
  31. 31. Rest Data Element (cont.)• safe : no side effect, The word "safe" means that if a given HTTP method is invoked, the resource state on the server remains unchanged• The word "idempotent" means that, regardless of how many times a given method is invoked, the end result is the same.• GET is always safe. No matter how many times you download this web page, the contents of it will not change due to your repeated downloads, since you cannot change the web page in that way.
  32. 32. 1. All replies to queries are expressed as JSON objects. 2. The general form, which all query replies share, is an array of arrays. 3. The inner array contains a map with two elements: command and reply. 4. “command” is that portion of the query which is being responded to with this entry; 5. “reply” is the query contents in response to the command portion. For example, the response to …/fetch?shelf=48 would be a configuration of shelf 48 encoded as a JSON stream as follows:[[{"command":"shelf=48"}, {"reply":[{"numberOfPools":3,"totalPoolStorage":3000633,"percentPoolStorageAllocated":20,"numberOfLvs":7,"numberOfSnapshots":129,"type":"VSX3500","eladdr":"5100002590357054","model":"VSX3500-G6","release":"VSX-1.3.5","origRelease":"VSX-1.3.5","serial":"CVS3500G60A000000000057","numAvailDisks":0,"uptime":"19days 19:43:39","idPath":"shelf=48"}]}]]

×