Representational State Transfer (REST). What is REST? Network Architectural style Overview:...
-
Upload
adrian-carroll -
Category
Documents
-
view
227 -
download
0
Transcript of Representational State Transfer (REST). What is REST? Network Architectural style Overview:...
![Page 1: Representational State Transfer (REST). What is REST? Network Architectural style Overview: –Resources are defined and addressed –Transmits domain-specific.](https://reader035.fdocuments.net/reader035/viewer/2022062309/5697bfcf1a28abf838caa20b/html5/thumbnails/1.jpg)
Representational State Transfer (REST)
![Page 2: Representational State Transfer (REST). What is REST? Network Architectural style Overview: –Resources are defined and addressed –Transmits domain-specific.](https://reader035.fdocuments.net/reader035/viewer/2022062309/5697bfcf1a28abf838caa20b/html5/thumbnails/2.jpg)
What is REST?
• Network Architectural style
• Overview:– Resources are defined and addressed– Transmits domain-specific data over HTTP
![Page 3: Representational State Transfer (REST). What is REST? Network Architectural style Overview: –Resources are defined and addressed –Transmits domain-specific.](https://reader035.fdocuments.net/reader035/viewer/2022062309/5697bfcf1a28abf838caa20b/html5/thumbnails/3.jpg)
REST is not a standard
• No W3C specification (EDIT: But there is an
XML database that has such an API: eXist)• REST is built on the concepts:
– HTTP (transferring mechanism)– URL (resource address)– XML/HTML/GIF/JPEG (Resource representations)– text/xml, text/html, image/gif, image/jpeg (MIME
types)
![Page 4: Representational State Transfer (REST). What is REST? Network Architectural style Overview: –Resources are defined and addressed –Transmits domain-specific.](https://reader035.fdocuments.net/reader035/viewer/2022062309/5697bfcf1a28abf838caa20b/html5/thumbnails/4.jpg)
Web services: example
• Build a web service to enable its customers to– Get list of items– Get details about a particular item– Purchase Order (PO)
![Page 5: Representational State Transfer (REST). What is REST? Network Architectural style Overview: –Resources are defined and addressed –Transmits domain-specific.](https://reader035.fdocuments.net/reader035/viewer/2022062309/5697bfcf1a28abf838caa20b/html5/thumbnails/5.jpg)
Web
Ser
ver
HTTP POST PO.xmlPO
(HTML/XML)
HTTP GET request /items
HTTP responseURL to submitted PO
List ofItems
ItemData
PO
HTTP responseResponse(HTML/XML doc)
HTTP responseResponse(HTML/XML doc)
HTTP GET request /00345Time
A user session
![Page 6: Representational State Transfer (REST). What is REST? Network Architectural style Overview: –Resources are defined and addressed –Transmits domain-specific.](https://reader035.fdocuments.net/reader035/viewer/2022062309/5697bfcf1a28abf838caa20b/html5/thumbnails/6.jpg)
Get list of items
• Access the URL: http://www.company.com/items• How the list is generated is invisible to the user (loose coupling)• The following XML document returned:
• Each item is retrieved via other links (key feature)
![Page 7: Representational State Transfer (REST). What is REST? Network Architectural style Overview: –Resources are defined and addressed –Transmits domain-specific.](https://reader035.fdocuments.net/reader035/viewer/2022062309/5697bfcf1a28abf838caa20b/html5/thumbnails/7.jpg)
Get detail of an item• Accessing the URL: http://www.company.com/items/00345• Any data change will not affect the user as in accessing
http://www.company.com/items/00345.html (restricts the resource; whereas a database could be underneath)
• Again, more in-depth links appear, enabling to more detailed information
![Page 8: Representational State Transfer (REST). What is REST? Network Architectural style Overview: –Resources are defined and addressed –Transmits domain-specific.](https://reader035.fdocuments.net/reader035/viewer/2022062309/5697bfcf1a28abf838caa20b/html5/thumbnails/8.jpg)
Characteristics• Traversing links pulls representations (pull-based client-server
interaction)• Each request must be self-sufficient, not taking advantage of any
store resource (stateless)• Capability of storing responses to frequent requests (cacheable or
non-cacheable)• Resources are access via (HTTP) GET, POST, PUT, DELETE
(uniform interface)• Every resource is named using an URL (named resources)• Resources are interconnected using URLs (interconnected resource
representations)• Intermediate components, e.g. proxy servers, gateways, firewalls,
etc. can be inserted between clients and resources for performance, security (layered components)
![Page 9: Representational State Transfer (REST). What is REST? Network Architectural style Overview: –Resources are defined and addressed –Transmits domain-specific.](https://reader035.fdocuments.net/reader035/viewer/2022062309/5697bfcf1a28abf838caa20b/html5/thumbnails/9.jpg)
Steps in creating a RESTful system
1. Identify resources, e.g. list of items, detail of an item, purchase order
2. Create a URL for every resource[use nouns, not verbs]
http://www.company.com/items/00345Instead of
http://www.company.com/items/getItem?id=003453. Categorize resources:
• Accessible via HTTP GET (read-only)• Accessible also via POST, PUT, DELETE (modifiable)
4. Connect resources through hyperlinks 5. Specify the format of the response using a schema, e.g. DTD,
W3C schema, RelaxNG (also take care of POST or PUT services)
6. Describe how your services should be invoked (in a WSDL or HTML document)
![Page 10: Representational State Transfer (REST). What is REST? Network Architectural style Overview: –Resources are defined and addressed –Transmits domain-specific.](https://reader035.fdocuments.net/reader035/viewer/2022062309/5697bfcf1a28abf838caa20b/html5/thumbnails/10.jpg)
REST Constrains (2)
• Uniform interface constrain– Implementation decoupled from interfaces- Adapting degrades efficiency
- Layered system constraint- Architecture can be build hierarchically- Added Overhead
- Code-on-demand (inactive code is executed on the client when the user requests it)
![Page 11: Representational State Transfer (REST). What is REST? Network Architectural style Overview: –Resources are defined and addressed –Transmits domain-specific.](https://reader035.fdocuments.net/reader035/viewer/2022062309/5697bfcf1a28abf838caa20b/html5/thumbnails/11.jpg)
Advantage to SOAP technologyStructure Accessibility Extensibility Performance Security
REST Inter-connections
(hyperlinks)
GET, PUT, POST,
DELETE
(uniform interface)
Yes, through links
GET-base URIs are cacheable
Can apply {GET, PUT, POST, DELETE} permissions to a data object
SOAP RPC
OO paradigm of encapsulating
data
Specific and numerous methods
Cannot refer to other objects outside the system
Not cached by any existing technology
Have to implement suitable strategy
![Page 12: Representational State Transfer (REST). What is REST? Network Architectural style Overview: –Resources are defined and addressed –Transmits domain-specific.](https://reader035.fdocuments.net/reader035/viewer/2022062309/5697bfcf1a28abf838caa20b/html5/thumbnails/12.jpg)
![Page 13: Representational State Transfer (REST). What is REST? Network Architectural style Overview: –Resources are defined and addressed –Transmits domain-specific.](https://reader035.fdocuments.net/reader035/viewer/2022062309/5697bfcf1a28abf838caa20b/html5/thumbnails/13.jpg)
![Page 14: Representational State Transfer (REST). What is REST? Network Architectural style Overview: –Resources are defined and addressed –Transmits domain-specific.](https://reader035.fdocuments.net/reader035/viewer/2022062309/5697bfcf1a28abf838caa20b/html5/thumbnails/14.jpg)
![Page 15: Representational State Transfer (REST). What is REST? Network Architectural style Overview: –Resources are defined and addressed –Transmits domain-specific.](https://reader035.fdocuments.net/reader035/viewer/2022062309/5697bfcf1a28abf838caa20b/html5/thumbnails/15.jpg)
![Page 16: Representational State Transfer (REST). What is REST? Network Architectural style Overview: –Resources are defined and addressed –Transmits domain-specific.](https://reader035.fdocuments.net/reader035/viewer/2022062309/5697bfcf1a28abf838caa20b/html5/thumbnails/16.jpg)
![Page 17: Representational State Transfer (REST). What is REST? Network Architectural style Overview: –Resources are defined and addressed –Transmits domain-specific.](https://reader035.fdocuments.net/reader035/viewer/2022062309/5697bfcf1a28abf838caa20b/html5/thumbnails/17.jpg)