Download - Integrating RESTfully
![Page 1: Integrating RESTfully](https://reader035.vdocument.in/reader035/viewer/2022062418/554f38fcb4c90572088b4de9/html5/thumbnails/1.jpg)
Integrating RestfullySrihari Srinivasan
ThoughtWorks
![Page 2: Integrating RESTfully](https://reader035.vdocument.in/reader035/viewer/2022062418/554f38fcb4c90572088b4de9/html5/thumbnails/2.jpg)
Platform for software development
Web 2.0
![Page 3: Integrating RESTfully](https://reader035.vdocument.in/reader035/viewer/2022062418/554f38fcb4c90572088b4de9/html5/thumbnails/3.jpg)
![Page 4: Integrating RESTfully](https://reader035.vdocument.in/reader035/viewer/2022062418/554f38fcb4c90572088b4de9/html5/thumbnails/4.jpg)
![Page 5: Integrating RESTfully](https://reader035.vdocument.in/reader035/viewer/2022062418/554f38fcb4c90572088b4de9/html5/thumbnails/5.jpg)
1 : 3
![Page 6: Integrating RESTfully](https://reader035.vdocument.in/reader035/viewer/2022062418/554f38fcb4c90572088b4de9/html5/thumbnails/6.jpg)
• REST - Representational State Transfer
• Term coined by Roy Fielding in his Ph.d thesis
Primer on REST
![Page 7: Integrating RESTfully](https://reader035.vdocument.in/reader035/viewer/2022062418/554f38fcb4c90572088b4de9/html5/thumbnails/7.jpg)
![Page 8: Integrating RESTfully](https://reader035.vdocument.in/reader035/viewer/2022062418/554f38fcb4c90572088b4de9/html5/thumbnails/8.jpg)
Principled Architecture / Design
of
Large Scale Distributed Systems
![Page 9: Integrating RESTfully](https://reader035.vdocument.in/reader035/viewer/2022062418/554f38fcb4c90572088b4de9/html5/thumbnails/9.jpg)
• Architectural style followed by the Web
• Its Generic, can be used to build other web-like systems
Primer on REST
![Page 10: Integrating RESTfully](https://reader035.vdocument.in/reader035/viewer/2022062418/554f38fcb4c90572088b4de9/html5/thumbnails/10.jpg)
• Performance, Scalability, Interoperability
• Simplicity, Extensibility
• Visibility of Interactions
• Reliability
Qualities
![Page 11: Integrating RESTfully](https://reader035.vdocument.in/reader035/viewer/2022062418/554f38fcb4c90572088b4de9/html5/thumbnails/11.jpg)
REST intentionally places
Constraints on the system to achieve Desired Properties
![Page 12: Integrating RESTfully](https://reader035.vdocument.in/reader035/viewer/2022062418/554f38fcb4c90572088b4de9/html5/thumbnails/12.jpg)
• Not a standard, an architectural style
• Standards based on this style - HTTP, ATOM
• Ignores implementation details of components and protocol syntax
REST - What it is not
![Page 13: Integrating RESTfully](https://reader035.vdocument.in/reader035/viewer/2022062418/554f38fcb4c90572088b4de9/html5/thumbnails/13.jpg)
• Not the ONLY style for governing network interactions.
• Event Driven Architectures
• Message Oriented Architecture
• and good old RPC...
• Most large systems have hybrid styles, one style may dominate though!
REST - What it is not
![Page 14: Integrating RESTfully](https://reader035.vdocument.in/reader035/viewer/2022062418/554f38fcb4c90572088b4de9/html5/thumbnails/14.jpg)
REST Constraints
![Page 15: Integrating RESTfully](https://reader035.vdocument.in/reader035/viewer/2022062418/554f38fcb4c90572088b4de9/html5/thumbnails/15.jpg)
REST Constraints
• Client-Server
• Statelessness
• Caching
• Layered System
• Uniform Interface
• Code on Demand (optional)
![Page 16: Integrating RESTfully](https://reader035.vdocument.in/reader035/viewer/2022062418/554f38fcb4c90572088b4de9/html5/thumbnails/16.jpg)
• Based on the principle of separation of concerns
• Client and Server can be developed, maintained and scaled independently
• Desired Properties : Simplicity, Scalability, Portability of user interfaces
Client-Server Style of Interactions
![Page 17: Integrating RESTfully](https://reader035.vdocument.in/reader035/viewer/2022062418/554f38fcb4c90572088b4de9/html5/thumbnails/17.jpg)
Uniform Interface
• The central/distinguishing feature of REST
• Most Controversial !
![Page 18: Integrating RESTfully](https://reader035.vdocument.in/reader035/viewer/2022062418/554f38fcb4c90572088b4de9/html5/thumbnails/18.jpg)
Uniform Interfaces are opposed to Specialized Interfaces
![Page 19: Integrating RESTfully](https://reader035.vdocument.in/reader035/viewer/2022062418/554f38fcb4c90572088b4de9/html5/thumbnails/19.jpg)
Specialized Interfaces
createEmployee(....)
updateEmployee(....)
getEmployeeDetails(identifier)
transferEmployee(identifier, to, ...)
deleteEmployee(identifier)
Employee Service
![Page 20: Integrating RESTfully](https://reader035.vdocument.in/reader035/viewer/2022062418/554f38fcb4c90572088b4de9/html5/thumbnails/20.jpg)
What happens when lots of such special interfaces
float in a distributed system ?
![Page 21: Integrating RESTfully](https://reader035.vdocument.in/reader035/viewer/2022062418/554f38fcb4c90572088b4de9/html5/thumbnails/21.jpg)
• Clients have to know
• Method names, parameters
• Semantics of the methods
• Possibly the order of method calls
• Each service interface is a new custom application protocol
• Clients cannot be generic
Specialization Consequences
![Page 22: Integrating RESTfully](https://reader035.vdocument.in/reader035/viewer/2022062418/554f38fcb4c90572088b4de9/html5/thumbnails/22.jpg)
Specialization Consequences
• RPC style tries to map local computing notions to distribute operations
• Leads to data specialization
• Therefore couples format of the data to the interface
![Page 23: Integrating RESTfully](https://reader035.vdocument.in/reader035/viewer/2022062418/554f38fcb4c90572088b4de9/html5/thumbnails/23.jpg)
How does the Uniform Interface constraint help ?
![Page 24: Integrating RESTfully](https://reader035.vdocument.in/reader035/viewer/2022062418/554f38fcb4c90572088b4de9/html5/thumbnails/24.jpg)
• RPC/Service style interfaces promote specialization along two dimensions
• Operations
• Data
Consequences of Specializing
![Page 25: Integrating RESTfully](https://reader035.vdocument.in/reader035/viewer/2022062418/554f38fcb4c90572088b4de9/html5/thumbnails/25.jpg)
More Constraints
![Page 26: Integrating RESTfully](https://reader035.vdocument.in/reader035/viewer/2022062418/554f38fcb4c90572088b4de9/html5/thumbnails/26.jpg)
REST discourages sending ad hoc messages, invoking special purpose functions
![Page 27: Integrating RESTfully](https://reader035.vdocument.in/reader035/viewer/2022062418/554f38fcb4c90572088b4de9/html5/thumbnails/27.jpg)
• Key Abstraction, Basic Unit of information
• Can be anything interesting
• spreadsheet, image, xml file, transaction etc
• Uniquely identifiable via a URI
Resources
![Page 28: Integrating RESTfully](https://reader035.vdocument.in/reader035/viewer/2022062418/554f38fcb4c90572088b4de9/html5/thumbnails/28.jpg)
• Manipulated using representations - "Pass-by-value" semantics
• All resources manipulated via a limited set of standard functions/operations
• In HTTP we have GET, POST, PUT & DELETE with well defined semantics for each
Resources
![Page 29: Integrating RESTfully](https://reader035.vdocument.in/reader035/viewer/2022062418/554f38fcb4c90572088b4de9/html5/thumbnails/29.jpg)
• Representations can be in any format
• Self describing messages help specify preferred formats
• Clients can even negotiate on formats with servers
Resources
![Page 30: Integrating RESTfully](https://reader035.vdocument.in/reader035/viewer/2022062418/554f38fcb4c90572088b4de9/html5/thumbnails/30.jpg)
How can a limited number of interfaces suffice to perform many
domain specific operations ?
![Page 31: Integrating RESTfully](https://reader035.vdocument.in/reader035/viewer/2022062418/554f38fcb4c90572088b4de9/html5/thumbnails/31.jpg)
• REST promotes replacing the "do something" concept with a "make something so" concept
• “What” and not “How”
• Think Declarative, instead of Imperative
Resources
![Page 32: Integrating RESTfully](https://reader035.vdocument.in/reader035/viewer/2022062418/554f38fcb4c90572088b4de9/html5/thumbnails/32.jpg)
Hypermedia as the engine of application state
![Page 33: Integrating RESTfully](https://reader035.vdocument.in/reader035/viewer/2022062418/554f38fcb4c90572088b4de9/html5/thumbnails/33.jpg)
• Representations must contain next steps/transitions a resource can make from the current state
• Use hyperlinks to define these transitions
Hypermedia
![Page 34: Integrating RESTfully](https://reader035.vdocument.in/reader035/viewer/2022062418/554f38fcb4c90572088b4de9/html5/thumbnails/34.jpg)
• HTTP GET from http://server.com/employees/name
• HTTP POST to http://server.coms/employees
• HTTP PUT to http://server.com/employees/name
• HTTP POST to http://server.com/employees/name/transfer
• HTTP DELETE to http://server.com/employees/name
Resource Orientation
![Page 35: Integrating RESTfully](https://reader035.vdocument.in/reader035/viewer/2022062418/554f38fcb4c90572088b4de9/html5/thumbnails/35.jpg)
• Model Resources, instead of services
• Assign identifiers to resources
• Expose uniform operations on resources based on your chosen protocol/framework
• Support multiple formats - “One size does not fit all”
• Leverage hypermedia to traverse through finite states
Resource Orientation
![Page 36: Integrating RESTfully](https://reader035.vdocument.in/reader035/viewer/2022062418/554f38fcb4c90572088b4de9/html5/thumbnails/36.jpg)
• REST tries to reveal the distribution in distributed systems
• Popularizes HTTP outside the browser
• Reminds us that HTTP is not a transport protocol
• The ideas of REST have merit even if you are doing classic SOA
• Not easy to grok, requires unlearning and relearning!
Summary
![Page 37: Integrating RESTfully](https://reader035.vdocument.in/reader035/viewer/2022062418/554f38fcb4c90572088b4de9/html5/thumbnails/37.jpg)
</presentation>