restful web servicesrestful web services at brookhaven lab nlit 2011 rich casella [email protected]...
TRANSCRIPT
![Page 1: RESTful Web ServicesRESTful Web Services at Brookhaven Lab NLIT 2011 Rich Casella rac@bnl.gov Brookhaven National Laboratory IT Division, Application Services 1. Disclaimer Notice:](https://reader033.vdocument.in/reader033/viewer/2022042301/5ecc6c5e6e5d5316ca3eaf96/html5/thumbnails/1.jpg)
RESTful Web Servicesat Brookhaven Lab
NLIT 2011
Rich [email protected]
Brookhaven National LaboratoryIT Division, Application Services
1
![Page 2: RESTful Web ServicesRESTful Web Services at Brookhaven Lab NLIT 2011 Rich Casella rac@bnl.gov Brookhaven National Laboratory IT Division, Application Services 1. Disclaimer Notice:](https://reader033.vdocument.in/reader033/viewer/2022042301/5ecc6c5e6e5d5316ca3eaf96/html5/thumbnails/2.jpg)
Disclaimer
Notice: This presentation was authored by employees of Brookhaven National Laboratory, under Contract No. DE-AC02-98CH10886 with the U.S. Department of Energy. The United States Government retains a non-exclusive, paid-up, irrevocable, world-wide license to publish or reproduce the published form of this presentation, or allow others to do so, for United States Government purposes.
2
2
![Page 3: RESTful Web ServicesRESTful Web Services at Brookhaven Lab NLIT 2011 Rich Casella rac@bnl.gov Brookhaven National Laboratory IT Division, Application Services 1. Disclaimer Notice:](https://reader033.vdocument.in/reader033/viewer/2022042301/5ecc6c5e6e5d5316ca3eaf96/html5/thumbnails/3.jpg)
Caveat
This is not a SOAP vs REST talk Choose the tool that is right for you based on your
own design considerations
3
3
![Page 4: RESTful Web ServicesRESTful Web Services at Brookhaven Lab NLIT 2011 Rich Casella rac@bnl.gov Brookhaven National Laboratory IT Division, Application Services 1. Disclaimer Notice:](https://reader033.vdocument.in/reader033/viewer/2022042301/5ecc6c5e6e5d5316ca3eaf96/html5/thumbnails/4.jpg)
About this talk
Brief description of RESTful Design Considerations Implementation Outstanding Issues Future Questions
4
4
![Page 5: RESTful Web ServicesRESTful Web Services at Brookhaven Lab NLIT 2011 Rich Casella rac@bnl.gov Brookhaven National Laboratory IT Division, Application Services 1. Disclaimer Notice:](https://reader033.vdocument.in/reader033/viewer/2022042301/5ecc6c5e6e5d5316ca3eaf96/html5/thumbnails/5.jpg)
What is REST REpresentational State Transfer Requests/responses relate to representations of
states of a resource Client/Server WWW Transfer Protocol Architecture Introduced by Roy Fielding in 2000 Resource Oriented Architecture
5
5
![Page 6: RESTful Web ServicesRESTful Web Services at Brookhaven Lab NLIT 2011 Rich Casella rac@bnl.gov Brookhaven National Laboratory IT Division, Application Services 1. Disclaimer Notice:](https://reader033.vdocument.in/reader033/viewer/2022042301/5ecc6c5e6e5d5316ca3eaf96/html5/thumbnails/6.jpg)
RESTful Constraints
Client-Server Stateless (no cookies) Cacheable (where possible) Uniform Interface Layered System Code On-Demand (optional)
6
6
![Page 7: RESTful Web ServicesRESTful Web Services at Brookhaven Lab NLIT 2011 Rich Casella rac@bnl.gov Brookhaven National Laboratory IT Division, Application Services 1. Disclaimer Notice:](https://reader033.vdocument.in/reader033/viewer/2022042301/5ecc6c5e6e5d5316ca3eaf96/html5/thumbnails/7.jpg)
Using RESTful Services
Uses simple HTTP protocol in practice, rather than SOAP or XMLRPC
Using HTTP methods:• GET: Return data, nothing is changed on server• POST: Create, update, or delete data on server• PUT: Replace referenced resource(s)• DELETE: Delete referenced resource(s)
7
7
![Page 8: RESTful Web ServicesRESTful Web Services at Brookhaven Lab NLIT 2011 Rich Casella rac@bnl.gov Brookhaven National Laboratory IT Division, Application Services 1. Disclaimer Notice:](https://reader033.vdocument.in/reader033/viewer/2022042301/5ecc6c5e6e5d5316ca3eaf96/html5/thumbnails/8.jpg)
SOAP/REST request comparison
SOAP<?xml version="1.0"?><soap:Envelope xmlns:soap="http://www.w3.org/2001/12/soap-envelope" soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding"> <soap:body pb="http://www.acme.com/phonebook"> <pb:GetUserDetails> <pb:UserID>12345</pb:UserID> </pb:GetUserDetails> </soap:Body></soap:Envelope>
RESThttp://www.acme.com/phonebook/UserDetails/12345
8
8
![Page 9: RESTful Web ServicesRESTful Web Services at Brookhaven Lab NLIT 2011 Rich Casella rac@bnl.gov Brookhaven National Laboratory IT Division, Application Services 1. Disclaimer Notice:](https://reader033.vdocument.in/reader033/viewer/2022042301/5ecc6c5e6e5d5316ca3eaf96/html5/thumbnails/9.jpg)
RESTful Pros
•Simple interface (URI based)•Uses HTTP service methods (GET, POST, ...)•Cacheing can be leveraged for performance•Small learning curve•Simple to test (browser compatible)•Less reliance on tools•No standard
9
9
![Page 10: RESTful Web ServicesRESTful Web Services at Brookhaven Lab NLIT 2011 Rich Casella rac@bnl.gov Brookhaven National Laboratory IT Division, Application Services 1. Disclaimer Notice:](https://reader033.vdocument.in/reader033/viewer/2022042301/5ecc6c5e6e5d5316ca3eaf96/html5/thumbnails/10.jpg)
RESTful Cons Not yet well integrated into IDE’s (but getting better) Security relies on HTTP authentication * Less reliance on tools * No standard
10
10
![Page 11: RESTful Web ServicesRESTful Web Services at Brookhaven Lab NLIT 2011 Rich Casella rac@bnl.gov Brookhaven National Laboratory IT Division, Application Services 1. Disclaimer Notice:](https://reader033.vdocument.in/reader033/viewer/2022042301/5ecc6c5e6e5d5316ca3eaf96/html5/thumbnails/11.jpg)
RESTful Players Amazon Web Services Google Maps Yahoo
11
11
![Page 12: RESTful Web ServicesRESTful Web Services at Brookhaven Lab NLIT 2011 Rich Casella rac@bnl.gov Brookhaven National Laboratory IT Division, Application Services 1. Disclaimer Notice:](https://reader033.vdocument.in/reader033/viewer/2022042301/5ecc6c5e6e5d5316ca3eaf96/html5/thumbnails/12.jpg)
Design Considerations Data• *NIX configuration data
- Configuration files- NIC data- OS signature- Process data
• Cyber Security compliance data- Disk encryption type- Accounts/User logins- Package/software versions
12
12
![Page 13: RESTful Web ServicesRESTful Web Services at Brookhaven Lab NLIT 2011 Rich Casella rac@bnl.gov Brookhaven National Laboratory IT Division, Application Services 1. Disclaimer Notice:](https://reader033.vdocument.in/reader033/viewer/2022042301/5ecc6c5e6e5d5316ca3eaf96/html5/thumbnails/13.jpg)
Design Considerations
Diverse customer base drives different output requirements• Human readable (reports)
- Cyber Security- Management
• Non-human readable - System Administrators- Web Designers
RESTful architecture allows for different output formats
13
13
![Page 14: RESTful Web ServicesRESTful Web Services at Brookhaven Lab NLIT 2011 Rich Casella rac@bnl.gov Brookhaven National Laboratory IT Division, Application Services 1. Disclaimer Notice:](https://reader033.vdocument.in/reader033/viewer/2022042301/5ecc6c5e6e5d5316ca3eaf96/html5/thumbnails/14.jpg)
URI Construction
Resource Oriented• URI to resource returns API/Usage• URI to resource details returns data
Examples• API/Usage
- http://webservices.bnl.gov/ordo- http://webservices.bnl.gov/ordo/packages- http://webservices.bnl.gov/ordo/status
• Details- http://webservices.bnl.gov/packages/130.199.130.70- http://webservices.bnl.gov/packages/package/openssl- http://webservices.bnl.gov/ordo/setOSStatus/supported
14
14
![Page 15: RESTful Web ServicesRESTful Web Services at Brookhaven Lab NLIT 2011 Rich Casella rac@bnl.gov Brookhaven National Laboratory IT Division, Application Services 1. Disclaimer Notice:](https://reader033.vdocument.in/reader033/viewer/2022042301/5ecc6c5e6e5d5316ca3eaf96/html5/thumbnails/15.jpg)
Output Format
Gather requirements from all users Support both human and non-human readable output Report Formats• (X)HTML (human readable)
- Straightforward design using existing tools and templates for standard formatting.
• XML (non-human readable)
15
15
![Page 16: RESTful Web ServicesRESTful Web Services at Brookhaven Lab NLIT 2011 Rich Casella rac@bnl.gov Brookhaven National Laboratory IT Division, Application Services 1. Disclaimer Notice:](https://reader033.vdocument.in/reader033/viewer/2022042301/5ecc6c5e6e5d5316ca3eaf96/html5/thumbnails/16.jpg)
XML
Design XML schema for output data to ensure well-formed response to data requests• Report Data
- Include XML schema location (show XML)- Use tools for standard formatting (Hash-based)
• Error Data- Use standard HTTP errors where applicable
- (404) Not Found- (503) Service Unavailable
- Create library of application specific errors- Return both error code and error text from library call (XML)
16
16
![Page 17: RESTful Web ServicesRESTful Web Services at Brookhaven Lab NLIT 2011 Rich Casella rac@bnl.gov Brookhaven National Laboratory IT Division, Application Services 1. Disclaimer Notice:](https://reader033.vdocument.in/reader033/viewer/2022042301/5ecc6c5e6e5d5316ca3eaf96/html5/thumbnails/17.jpg)
ImplementationPerl CGI on Apache web server
Dual homed to handle different output formats
[apps@toolbox5 cgi-bin]$ ls -l
total 64
-rw-r----- 1 apps app-www 0 Mar 18 09:20 index.html
-rwxr-x--- 1 apps app-www 6745 May 13 12:50 ordo
-rwxr-x--- 1 apps app-www 9182 May 16 15:11 setOSStatus
drwxr-s--- 2 apps app-www 4096 May 17 11:08 WS
[apps@toolbox5 cgi-bin]$ ls -l WS
total 40
-rw-r----- 1 apps app-www 0 Apr 28 10:14 index.html
-rwxr-x--- 1 apps app-www 6116 May 16 11:09 ordo
-rwxr-x--- 1 apps app-www 8370 May 17 11:05 setOSStatus
URI: http://webservices.bnl.gov/cgi-bin/ordo
URI: http://webservices.bnl.gov/cgi-bin/WS/ordo
17
17
![Page 18: RESTful Web ServicesRESTful Web Services at Brookhaven Lab NLIT 2011 Rich Casella rac@bnl.gov Brookhaven National Laboratory IT Division, Application Services 1. Disclaimer Notice:](https://reader033.vdocument.in/reader033/viewer/2022042301/5ecc6c5e6e5d5316ca3eaf96/html5/thumbnails/18.jpg)
Outstanding Issues
Authentication Not completely there yet• non-cacheing
XML to (X)HTML
18
18
![Page 19: RESTful Web ServicesRESTful Web Services at Brookhaven Lab NLIT 2011 Rich Casella rac@bnl.gov Brookhaven National Laboratory IT Division, Application Services 1. Disclaimer Notice:](https://reader033.vdocument.in/reader033/viewer/2022042301/5ecc6c5e6e5d5316ca3eaf96/html5/thumbnails/19.jpg)
Questions?
19
19
![Page 20: RESTful Web ServicesRESTful Web Services at Brookhaven Lab NLIT 2011 Rich Casella rac@bnl.gov Brookhaven National Laboratory IT Division, Application Services 1. Disclaimer Notice:](https://reader033.vdocument.in/reader033/viewer/2022042301/5ecc6c5e6e5d5316ca3eaf96/html5/thumbnails/20.jpg)
Resources Rich Casella - [email protected] Learn REST: A Tutorial:• http://rest.elkstein.org
Fielding Dissertation:• http://www.ics.uci.edu/~fielding/pubs/
dissertation/top.htm
20
20