Cesare Pautasso R E S T V1
-
Upload
soa-symposium -
Category
Technology
-
view
1.845 -
download
2
description
Transcript of Cesare Pautasso R E S T V1
![Page 1: Cesare Pautasso R E S T V1](https://reader034.fdocuments.net/reader034/viewer/2022051608/53ffb30a8d7f7261088b46f7/html5/thumbnails/1.jpg)
Founding Sponsors
This Presentation Courtesy of the
International SOA Symposium
October 7-8, 2008 Amsterdam Arena
www.soasymposium.com
Gold Sponsors
Platinum Sponsors
Silver Sponsors
![Page 2: Cesare Pautasso R E S T V1](https://reader034.fdocuments.net/reader034/viewer/2022051608/53ffb30a8d7f7261088b46f7/html5/thumbnails/2.jpg)
7.10.2008 SOA Symposium 2008, Amsterdam©2008 Cesare Pautasso
1
REST vs. SOAP: Making the Right
Architectural Decision
Cesare PautassoFaculty of Informatics
University of Lugano (USI), Switzerlandhttp://www.pautasso.info
![Page 3: Cesare Pautasso R E S T V1](https://reader034.fdocuments.net/reader034/viewer/2022051608/53ffb30a8d7f7261088b46f7/html5/thumbnails/3.jpg)
7.10.2008 SOA Symposium 2008, Amsterdam©2008 Cesare Pautasso
2
Agenda
1. Motivation: A short history of Web Services2. Comparing REST vs. SOAP/WS-*3. Architectural Decision Modeling4. Conceptual Comparison5. Technology Comparison6. How to measure the “complexity” of WS-*
or the “simplicity” of REST?7. Conclusion: Making the right Architectural
Decision
![Page 4: Cesare Pautasso R E S T V1](https://reader034.fdocuments.net/reader034/viewer/2022051608/53ffb30a8d7f7261088b46f7/html5/thumbnails/4.jpg)
7.10.2008 SOA Symposium 2008, Amsterdam©2008 Cesare Pautasso
3
Web Sites (1992)
HTTP
HTMLWeb Browser
Web Server
(HTTP)
SOAP
ServerClient XML
WSDL
WS-* Web Services (2000)
![Page 5: Cesare Pautasso R E S T V1](https://reader034.fdocuments.net/reader034/viewer/2022051608/53ffb30a8d7f7261088b46f7/html5/thumbnails/5.jpg)
7.10.2008 SOA Symposium 2008, Amsterdam©2008 Cesare Pautasso
4
RESTful Web Services (2006)
ClientHTTP
PO-XM
L
RSS
JSON
Web Server
WADL
WS-* Web Services (2000)
(HTTP)
SOAP
ServerClient XML
WSDL
![Page 6: Cesare Pautasso R E S T V1](https://reader034.fdocuments.net/reader034/viewer/2022051608/53ffb30a8d7f7261088b46f7/html5/thumbnails/6.jpg)
7.10.2008 SOA Symposium 2008, Amsterdam©2008 Cesare Pautasso
5
![Page 7: Cesare Pautasso R E S T V1](https://reader034.fdocuments.net/reader034/viewer/2022051608/53ffb30a8d7f7261088b46f7/html5/thumbnails/7.jpg)
7.10.2008 SOA Symposium 2008, Amsterdam©2008 Cesare Pautasso
6
XML
URI HTTP
MIME
JSON
RESTful
SSL
RSS
![Page 8: Cesare Pautasso R E S T V1](https://reader034.fdocuments.net/reader034/viewer/2022051608/53ffb30a8d7f7261088b46f7/html5/thumbnails/8.jpg)
7.10.2008 SOA Symposium 2008, Amsterdam©2008 Cesare Pautasso
7
Is REST being used?Slide from
Paul Dow
ney, BT
![Page 9: Cesare Pautasso R E S T V1](https://reader034.fdocuments.net/reader034/viewer/2022051608/53ffb30a8d7f7261088b46f7/html5/thumbnails/9.jpg)
7.10.2008 SOA Symposium 2008, Amsterdam©2008 Cesare Pautasso
8
Can we really compare WS-* vs. REST?
WS-* REST
![Page 10: Cesare Pautasso R E S T V1](https://reader034.fdocuments.net/reader034/viewer/2022051608/53ffb30a8d7f7261088b46f7/html5/thumbnails/10.jpg)
7.10.2008 SOA Symposium 2008, Amsterdam©2008 Cesare Pautasso
9
Can we really compare WS-* vs. REST?
WS-*
SOA MiddlewareInteroperability
Standards
REST
Architecturalstyle for the Web
![Page 11: Cesare Pautasso R E S T V1](https://reader034.fdocuments.net/reader034/viewer/2022051608/53ffb30a8d7f7261088b46f7/html5/thumbnails/11.jpg)
7.10.2008 SOA Symposium 2008, Amsterdam©2008 Cesare Pautasso
10
How to compare?
WS-*
SOA MiddlewareInteroperability
Standards
REST
Architecturalstyle for the Web
Architectural
Decision Modeling
![Page 12: Cesare Pautasso R E S T V1](https://reader034.fdocuments.net/reader034/viewer/2022051608/53ffb30a8d7f7261088b46f7/html5/thumbnails/12.jpg)
7.10.2008 SOA Symposium 2008, Amsterdam©2008 Cesare Pautasso
11
Architectural Decisions
• Architectural decisions capture the main design issues and the rationale behind a chosen technical solution
• The choice between REST vs. WS-* is an important architectural decision forintegration projects
• Architectural decisions affect one another
Architectural Decision:Communication Protocol
Architecture Alternatives:1. TCP2. SMTP3. HTTP4. MQ5. BEEP6. CORBA IIOP7. …
Rationale
![Page 13: Cesare Pautasso R E S T V1](https://reader034.fdocuments.net/reader034/viewer/2022051608/53ffb30a8d7f7261088b46f7/html5/thumbnails/13.jpg)
7.10.2008 SOA Symposium 2008, Amsterdam©2008 Cesare Pautasso
12
Application Integration Styles
File Transfer
Shared Database
Message BusRemoteProcedure
Call
WS-*REST
Integration Technology Platform
![Page 14: Cesare Pautasso R E S T V1](https://reader034.fdocuments.net/reader034/viewer/2022051608/53ffb30a8d7f7261088b46f7/html5/thumbnails/14.jpg)
7.10.2008 SOA Symposium 2008, Amsterdam©2008 Cesare Pautasso
13
Related Decisions (WS-*)
File Transfer
Shared Database
Message BusRemoteProcedure
Call
WS-*REST
![Page 15: Cesare Pautasso R E S T V1](https://reader034.fdocuments.net/reader034/viewer/2022051608/53ffb30a8d7f7261088b46f7/html5/thumbnails/15.jpg)
7.10.2008 SOA Symposium 2008, Amsterdam©2008 Cesare Pautasso
14
Related Decisions (RPC)
File Transfer
Shared Database
Message BusRemoteProcedure
Call
WS-*REST
![Page 16: Cesare Pautasso R E S T V1](https://reader034.fdocuments.net/reader034/viewer/2022051608/53ffb30a8d7f7261088b46f7/html5/thumbnails/16.jpg)
7.10.2008 SOA Symposium 2008, Amsterdam©2008 Cesare Pautasso
15
Decision Space Overview
![Page 17: Cesare Pautasso R E S T V1](https://reader034.fdocuments.net/reader034/viewer/2022051608/53ffb30a8d7f7261088b46f7/html5/thumbnails/17.jpg)
7.10.2008 SOA Symposium 2008, Amsterdam©2008 Cesare Pautasso
16
Decision Space Summary
21 Decisions and 64 alternativesClassified by level of abstraction:• 3 Architectural Principles
• 9 Conceptual Decisions• 9 Technology-level Decisions
Decisions help us to measure the complexity implied by the choice of
REST or WS-*
![Page 18: Cesare Pautasso R E S T V1](https://reader034.fdocuments.net/reader034/viewer/2022051608/53ffb30a8d7f7261088b46f7/html5/thumbnails/18.jpg)
7.10.2008 SOA Symposium 2008, Amsterdam©2008 Cesare Pautasso
17
Architectural Principles
1. Protocol Layering• HTTP = Application-level Protocol (REST)• HTTP = Transport-level Protocol (WS-*)
2. Dealing with Heterogeneity3. Loose Coupling
![Page 19: Cesare Pautasso R E S T V1](https://reader034.fdocuments.net/reader034/viewer/2022051608/53ffb30a8d7f7261088b46f7/html5/thumbnails/19.jpg)
7.10.2008 SOA Symposium 2008, Amsterdam©2008 Cesare Pautasso
18
RESTful Web Service Example
HTTP Client
(Web Browser)
Web Server Database
GET /book?ISBN=222SELECT *
FROM books WHERE isbn=222
POST /order INSERT INTO orders301 Location: /order/612
PUT /order/612 UPDATE ordersWHERE id=612
![Page 20: Cesare Pautasso R E S T V1](https://reader034.fdocuments.net/reader034/viewer/2022051608/53ffb30a8d7f7261088b46f7/html5/thumbnails/20.jpg)
7.10.2008 SOA Symposium 2008, Amsterdam©2008 Cesare Pautasso
19
Big Web Service Example (from REST perspective)
HTTP Client
(Stub Object)
Web Server
POST /soap/endpoint
POST /soap/endpoint
POST /soap/endpoint
return getBook(222)
return new Order()
order.setCustomer(x)
Web Service
Implementation
![Page 21: Cesare Pautasso R E S T V1](https://reader034.fdocuments.net/reader034/viewer/2022051608/53ffb30a8d7f7261088b46f7/html5/thumbnails/21.jpg)
7.10.2008 SOA Symposium 2008, Amsterdam©2008 Cesare Pautasso
20
Protocol Layering• “The Web is the universe of globally
accessible information”(Tim Berners Lee)– Applications should publish their
data on the Web (through URI)
• “The Web is the universal (tunneling) transport for messages”– Applications get a chance to
interact but they remain “outside of the Web”
Application
Resource URI
HTTPPOST
Application
Endpoint URI
POX
HTTPGET
HTTPPUT
HTTPDEL
HTTPPOST
SOAP (WS-*)
MQ…SMTP
RSS JSON …
![Page 22: Cesare Pautasso R E S T V1](https://reader034.fdocuments.net/reader034/viewer/2022051608/53ffb30a8d7f7261088b46f7/html5/thumbnails/22.jpg)
7.10.2008 SOA Symposium 2008, Amsterdam©2008 Cesare Pautasso
21
Dealing with Heterogeneity
CICS
IMS
Picture from Eric N
ewcom
er, ION
A
• Enterprise Computing
HTTP
• Web Applications
![Page 23: Cesare Pautasso R E S T V1](https://reader034.fdocuments.net/reader034/viewer/2022051608/53ffb30a8d7f7261088b46f7/html5/thumbnails/23.jpg)
7.10.2008 SOA Symposium 2008, Amsterdam©2008 Cesare Pautasso
22
Conceptual Comparison
Note: this table will scroll up
during the talk
![Page 24: Cesare Pautasso R E S T V1](https://reader034.fdocuments.net/reader034/viewer/2022051608/53ffb30a8d7f7261088b46f7/html5/thumbnails/24.jpg)
7.10.2008 SOA Symposium 2008, Amsterdam©2008 Cesare Pautasso
23
Technology Comparison
Note: this table will scroll up
during the talk
![Page 25: Cesare Pautasso R E S T V1](https://reader034.fdocuments.net/reader034/viewer/2022051608/53ffb30a8d7f7261088b46f7/html5/thumbnails/25.jpg)
7.10.2008 SOA Symposium 2008, Amsterdam©2008 Cesare Pautasso
24
Measuring Complexity
• Architectural Decisions give a quantitative measure of the complexity of an architectural design space:– Total number of decisions– For each decision, number of alternative options– For each alternative option, estimate the effort
3527Alternatives1417Decisions
WS-*REST
Decisions with 1 or more alternative options
![Page 26: Cesare Pautasso R E S T V1](https://reader034.fdocuments.net/reader034/viewer/2022051608/53ffb30a8d7f7261088b46f7/html5/thumbnails/26.jpg)
7.10.2008 SOA Symposium 2008, Amsterdam©2008 Cesare Pautasso
25
Measuring Complexity
3527Alternatives1417Decisions
WS-*REST
Decisions with 1 or more alternative options
3216Alternatives125Decisions
WS-*REST
Decisions with more than 1 alternative options
![Page 27: Cesare Pautasso R E S T V1](https://reader034.fdocuments.net/reader034/viewer/2022051608/53ffb30a8d7f7261088b46f7/html5/thumbnails/27.jpg)
7.10.2008 SOA Symposium 2008, Amsterdam©2008 Cesare Pautasso
26
Measuring Complexity
3216Alternatives
125Decisions
WS-*REST
Decisions with more than 1 alternative options
• URI Design• Resource Interaction Semantics
• Payload Format• Service Description• Service Composition
![Page 28: Cesare Pautasso R E S T V1](https://reader034.fdocuments.net/reader034/viewer/2022051608/53ffb30a8d7f7261088b46f7/html5/thumbnails/28.jpg)
7.10.2008 SOA Symposium 2008, Amsterdam©2008 Cesare Pautasso
27
Measuring Complexity
3216Alternatives125Decisions
WS-*REST
Decisions with more than 1 alternative options
212Decisions
WS-*REST
Decisions with only 1 alternative option
![Page 29: Cesare Pautasso R E S T V1](https://reader034.fdocuments.net/reader034/viewer/2022051608/53ffb30a8d7f7261088b46f7/html5/thumbnails/29.jpg)
7.10.2008 SOA Symposium 2008, Amsterdam©2008 Cesare Pautasso
28
Measuring Complexity
212Decisions
WS-*REST
Decisions with only 1 alternative option
• Payload Format• Data Representation Modeling
![Page 30: Cesare Pautasso R E S T V1](https://reader034.fdocuments.net/reader034/viewer/2022051608/53ffb30a8d7f7261088b46f7/html5/thumbnails/30.jpg)
7.10.2008 SOA Symposium 2008, Amsterdam©2008 Cesare Pautasso
29
Measuring Effort
212Decisions
WS-*REST
Decisions with only 1 alternative option
05Do-it-yourself Alternatives
WS-*REST
Decisions with only do-it-yourself alternatives
![Page 31: Cesare Pautasso R E S T V1](https://reader034.fdocuments.net/reader034/viewer/2022051608/53ffb30a8d7f7261088b46f7/html5/thumbnails/31.jpg)
7.10.2008 SOA Symposium 2008, Amsterdam©2008 Cesare Pautasso
30
Measuring Effort
05Do-it-yourself Alternatives
WS-*REST
Decisions with only do-it-yourself alternatives
• Resource Identification• Resource Relationship
• Reliability• Transactions• Service Discovery
![Page 32: Cesare Pautasso R E S T V1](https://reader034.fdocuments.net/reader034/viewer/2022051608/53ffb30a8d7f7261088b46f7/html5/thumbnails/32.jpg)
7.10.2008 SOA Symposium 2008, Amsterdam©2008 Cesare Pautasso
31
Freedom of ChoiceFreedom from Choice
![Page 33: Cesare Pautasso R E S T V1](https://reader034.fdocuments.net/reader034/viewer/2022051608/53ffb30a8d7f7261088b46f7/html5/thumbnails/33.jpg)
7.10.2008 SOA Symposium 2008, Amsterdam©2008 Cesare Pautasso
32
Comparison Summary
• Architectural Decisions measure complexity implied by alternative technologies
• REST simplicity = freedom from choice– 5 decisions require to choose among 16 alternatives– 12 decisions are already taken (but 5 are do-it-yourself)
• WS-* complexity = freedom of choice– 12 decisions require to choose among 32 alternatives– 2 decisions are already taken (SOAP, WSDL+XSD)
![Page 34: Cesare Pautasso R E S T V1](https://reader034.fdocuments.net/reader034/viewer/2022051608/53ffb30a8d7f7261088b46f7/html5/thumbnails/34.jpg)
7.10.2008 SOA Symposium 2008, Amsterdam©2008 Cesare Pautasso
33
Conclusion
• You should focus on whatever solution gets the job done and try to avoid being religious about any specific architectures or technologies.
• WS-* has strengths and weaknesses and will be highly suitable to some applications and positively terrible for others. Likewise with REST.
• The decision of which to use depends entirely on the application requirements and constraints.
• We hope this comparison will help you make the right choice.
![Page 35: Cesare Pautasso R E S T V1](https://reader034.fdocuments.net/reader034/viewer/2022051608/53ffb30a8d7f7261088b46f7/html5/thumbnails/35.jpg)
7.10.2008 SOA Symposium 2008, Amsterdam©2008 Cesare Pautasso
34
References
• Cesare Pautasso, Olaf Zimmermann, Frank Leymann, RESTful Web Services vs. Big Web Services: Making the Right Architectural Decision, Proc. of the 17th International World Wide Web Conference (WWW2008), Bejing, China, April 2008.
• Cesare Pautasso, BPEL for REST, Proc. of the 6th International Conference on Business Process Management (BPM 2008), Milan, Italy, September 2008.
• Cesare Pautasso, Gustavo Alonso: From Web Service Composition to Megaprogramming In: Proceedings of the 5th VLDB Workshop on Technologies for E-Services (TES-04), Toronto, Canada, August 29-30, 2004.
![Page 36: Cesare Pautasso R E S T V1](https://reader034.fdocuments.net/reader034/viewer/2022051608/53ffb30a8d7f7261088b46f7/html5/thumbnails/36.jpg)
7.10.2008 SOA Symposium 2008, Amsterdam©2008 Cesare Pautasso
35
REST vs. SOAP: Making the Right
Architectural Decision
Cesare PautassoFaculty of Informatics
University of Lugano (USI), Switzerlandhttp://www.pautasso.info
![Page 37: Cesare Pautasso R E S T V1](https://reader034.fdocuments.net/reader034/viewer/2022051608/53ffb30a8d7f7261088b46f7/html5/thumbnails/37.jpg)
7.10.2008 SOA Symposium 2008, Amsterdam©2008 Cesare Pautasso
36
Backup Materialon REST
Cesare PautassoFaculty of Informatics
University of Lugano (USI), Switzerlandhttp://www.pautasso.info
![Page 38: Cesare Pautasso R E S T V1](https://reader034.fdocuments.net/reader034/viewer/2022051608/53ffb30a8d7f7261088b46f7/html5/thumbnails/38.jpg)
7.10.2008 SOA Symposium 2008, Amsterdam©2008 Cesare Pautasso
37
REST in one Slide
• REpresentational State Transfer defines the architectural style of the World Wide Web
• Its four principles can explain the success and the scalability of the HTTP protocol implementing them
1. Resource Identification through URI2. Uniform Interface for all resources:
GET (Query the state, idempotent, can be cached)POST (Update a resource or create child resource)PUT (Transfer the state on existing/new resource)DELETE (Delete a resource)
3. “Self-Descriptive” Message representations4. Hyperlinks to define relationships between resources
and valid state transitions of the service interaction
![Page 39: Cesare Pautasso R E S T V1](https://reader034.fdocuments.net/reader034/viewer/2022051608/53ffb30a8d7f7261088b46f7/html5/thumbnails/39.jpg)
7.10.2008 SOA Symposium 2008, Amsterdam©2008 Cesare Pautasso
38
URI: Uniform Resource Identifier
• Internet Standard for resource naming and identification (originally from 1994, revised until 2005)
• Examples: http://tools.ietf.org/html/rfc3986
https://www.google.ch/search?q=rest&start=10#1
• REST advocates the use of “nice” URIs• In most HTTP stacks URIs cannot have arbitrary length (4Kb)
URI Scheme Authority Path
Query Fragment
![Page 40: Cesare Pautasso R E S T V1](https://reader034.fdocuments.net/reader034/viewer/2022051608/53ffb30a8d7f7261088b46f7/html5/thumbnails/40.jpg)
7.10.2008 SOA Symposium 2008, Amsterdam©2008 Cesare Pautasso
39
What is a “nice” URI?
http://map.search.ch/lugano
http://maps.google.com/maps?f=q&hl=en&q=lugano,+switzerland&layer=&ie=UTF8&z=12&om=1&iwloc=addr
http://maps.google.com/lugano
Prefer Nouns to Verbs
Keep them Short
![Page 41: Cesare Pautasso R E S T V1](https://reader034.fdocuments.net/reader034/viewer/2022051608/53ffb30a8d7f7261088b46f7/html5/thumbnails/41.jpg)
7.10.2008 SOA Symposium 2008, Amsterdam©2008 Cesare Pautasso
40
Uniform Interface Principle (CRUD Example)
DELETE
UPDATE
READ
CREATE
CRUD
Clear a resource, after the URI is no
longer valid
Modify the state of a resource
Retrieve the current state of the resource
Initialize the state of a new resource
at the given URI
DELETE
PUT
GET
POST/PUT
REST
![Page 42: Cesare Pautasso R E S T V1](https://reader034.fdocuments.net/reader034/viewer/2022051608/53ffb30a8d7f7261088b46f7/html5/thumbnails/42.jpg)
7.10.2008 SOA Symposium 2008, Amsterdam©2008 Cesare Pautasso
41
POST vs. GET
• GET is a read-only operation. It can be repeated without affecting the state of the resource (idem-potent)
• POST is a read-writeoperation and may change the state of the resource and provoke side effects on the server.Web browsers warn you when refreshing a page generated with POST
![Page 43: Cesare Pautasso R E S T V1](https://reader034.fdocuments.net/reader034/viewer/2022051608/53ffb30a8d7f7261088b46f7/html5/thumbnails/43.jpg)
7.10.2008 SOA Symposium 2008, Amsterdam©2008 Cesare Pautasso
42
RESTful Web Services Design
1. Identify resources to be exposed as services (e.g., yearly risk report, book catalog, purchase order, open bugs)
2. Define “nice” URLs to address them3. Understand what it means to do a GET,
POST, PUT, DELETE on a given resource URI
4. Design and document resource representations (payload formats)
5. Model relationships (e.g., containment, reference, state transitions) between resources with hyperlinks that can be followed to get more details
6. Implement and deploy on Web server7. Test with a Web browser
XXX/soap
??/order
/book
?/client
XXX/balance
/loan
DELETE
POST
PUT
GET
![Page 44: Cesare Pautasso R E S T V1](https://reader034.fdocuments.net/reader034/viewer/2022051608/53ffb30a8d7f7261088b46f7/html5/thumbnails/44.jpg)
7.10.2008 SOA Symposium 2008, Amsterdam©2008 Cesare Pautasso
43
• XML– PO-XML– SOAP (WS-*)– RSS, ATOM
• Standard textual syntax for semi-structured data
• Many tools available: XML Schema, DOM, SAX, XPath, XSLT, XQuery
• Everyone can parse it (not necessarily understand it)
• Slow and Verbose
• JavaScript Object Notation (JSON)• Wire format introduced for AJAX
Web applications (Browser-Web Server communication)
• Textual syntax for serialization of non-recurrent data structures
• Supported in most languages (not only JavaScript)
• Not extensible (does not need to be)
• “JSON has become the X in Ajax”
Resource Representation Formats: XML vs JSON