Jun 19, 2008 - Web. Server. (HTTP). SOAP. Server. Client. XML. WSDL. WS-* Web Services (2000) .... We hope this comparison will help you make the.
Web Services in 2008: to REST or not to REST? Cesare Pautasso Faculty of Informatics University of Lugano, CH http://www.pautasso.info
19.6.2008
3
University of Milano Bicocca, Italy ©2008 Cesare Pautasso
Web Sites (1992)
Web Browser
HTML HTTP
Web Server
WS-* Web Services (2000) SOAP Client 19.6.2008
XML (HTTP)
University of Milano Bicocca, Italy ©2008 Cesare Pautasso
WSDL Server 4
1
RESTful Web Services (2007) RSS
PO-XML
JSON
Client
HTTP
WADL Web Server
WS-* Web Services (2000) SOAP Client
XML (HTTP)
WSDL Server
19.6.2008
University of Milano Bicocca, Italy ©2008 Cesare Pautasso
5
19.6.2008
University of Milano Bicocca, Italy ©2008 Cesare Pautasso
6
2
RESTful
RSS XML
JSON
MIME URI
HTTP SSL
19.6.2008
7
University of Milano Bicocca, Italy ©2008 Cesare Pautasso
Is REST being used?
University of Milano Bicocca, Italy ©2008 Cesare Pautasso
Slide from Paul Downey, BT
19.6.2008
8
3
Can we really compare WS-* vs. REST?
REST
WS-*
19.6.2008
9
University of Milano Bicocca, Italy ©2008 Cesare Pautasso
Can we really compare WS-* vs. REST?
19.6.2008
WS-*
REST
Middleware Interoperability Standards
Architectural style for the Web
University of Milano Bicocca, Italy ©2008 Cesare Pautasso
10
4
How to compare?
ral Architectu ng odeli M n o i s i c e D
Architectural style for the Web
WS-* Middleware Interoperability Standards 19.6.2008
REST
University of Milano Bicocca, Italy ©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 for integration projects Architectural decisions affect one another
Architectural Decision: Communication Protocol Architecture Alternatives: 1. TCP 2. SMTP 3. HTTP 4. MQ 5. BEEP 6. CORBA IIOP 7. … Rationale
19.6.2008
University of Milano Bicocca, Italy ©2008 Cesare Pautasso
12
5
Application Integration Styles Shared Database
Remote Procedure Call
REST
Message Bus
File Transfer
WS-*
Integration Technology Platform 19.6.2008
13
University of Milano Bicocca, Italy ©2008 Cesare Pautasso
Related Decisions (WS-*) Remote Procedure Call
Shared Database
REST
19.6.2008
Message Bus
File Transfer
WS-*
University of Milano Bicocca, Italy ©2008 Cesare Pautasso
14
6
Related Decisions (RPC) Remote Procedure Call
Shared Database
REST
19.6.2008
Message Bus
File Transfer
WS-*
University of Milano Bicocca, Italy ©2008 Cesare Pautasso
15
Decision Space Overview
19.6.2008
University of Milano Bicocca, Italy ©2008 Cesare Pautasso
16
7
Outline 21 Decisions and 64 alternatives Classified 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-* 19.6.2008
University of Milano Bicocca, Italy ©2008 Cesare Pautasso
17
Architectural Principles 1. Protocol Layering • HTTP = Application-level Protocol (REST) • HTTP = Transport-level Protocol (WS-*)
2. Dealing with Heterogeneity 3. Loose Coupling
19.6.2008
University of Milano Bicocca, Italy ©2008 Cesare Pautasso
18
8
RESTful Web Service Example HTTP Client
Web Server
Database
(Web Browser)
GET /book?ISBN=222
SELECT * FROM books WHERE isbn=222
POST /order
INSERT INTO orders
301 Location: /order/612
UPDATE orders WHERE id=612
PUT /order/612 19.6.2008
19
University of Milano Bicocca, Italy ©2008 Cesare Pautasso
Big Web Service Example (from REST perspective) HTTP Client
Web Server
(Stub Object)
POST /soap/endpoint POST /soap/endpoint POST /soap/endpoint
19.6.2008
Web Service Implementation
return getBook(222) return new Order() order.setCustomer(x)
University of Milano Bicocca, Italy ©2008 Cesare Pautasso
20
9
Protocol Layering • “The Web is the universe of globally accessible information” (Tim Berners Lee) – Applications should publish their data on the Web (through URI)
POX
RSS
JSON
•
“The Web is the universal (tunneling) transport for messages” – Applications get a chance to interact but they remain “outside of the Web”
…
HTTP HTTP HTTP HTTP GET POST PUT DEL
SOAP (WS-*) SMTP
HTTP POST
MQ…
Resource URI
Endpoint URI
Application
Application
19.6.2008
21
University of Milano Bicocca, Italy ©2008 Cesare Pautasso
Dealing with Heterogeneity • Web Applications
• Enterprise Computing
CICS IMS
19.6.2008
University of Milano Bicocca, Italy ©2008 Cesare Pautasso
Picture from Eric Newcomer, IONA
HTTP
22
10
Conceptual Comparison
19.6.2008
University of Milano Bicocca, Italy ©2008 Cesare Pautasso
23
Technology Comparison
19.6.2008
University of Milano Bicocca, Italy ©2008 Cesare Pautasso
24
11
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
Decisions Alternatives
REST 17 27
WS-* 14 35
Decisions with 1 or more alternative options 19.6.2008
25
University of Milano Bicocca, Italy ©2008 Cesare Pautasso
Measuring Complexity Decisions Alternatives
REST 5 16
WS-* 12 32
Decisions with more than 1 alternative options
Decisions Alternatives
REST 17 27
WS-* 14 35
Decisions with 1 or more alternative options 19.6.2008
University of Milano Bicocca, Italy ©2008 Cesare Pautasso
26
12
Measuring Complexity Decisions Alternatives
REST 5 16
WS-* 12 32
Decisions with more than 1 alternative options
• •
URI Design Resource Interaction Semantics
• • •
Payload Format Service Description Service Composition
19.6.2008
27
University of Milano Bicocca, Italy ©2008 Cesare Pautasso
Measuring Complexity Decisions Alternatives
REST 5 16
WS-* 12 32
Decisions with more than 1 alternative options
Decisions
REST 12
WS-* 2
Decisions with only 1 alternative option 19.6.2008
University of Milano Bicocca, Italy ©2008 Cesare Pautasso
28
13
Measuring Complexity
• •
Decisions
Payload Format Data Representation Modeling
REST 12
WS-* 2
Decisions with only 1 alternative option 19.6.2008
29
University of Milano Bicocca, Italy ©2008 Cesare Pautasso
Measuring Effort Do-it-yourself Alternatives
REST 5
WS-* 0
Decisions with only do-it-yourself alternatives
Decisions
REST 12
WS-* 2
Decisions with only 1 alternative option 19.6.2008
University of Milano Bicocca, Italy ©2008 Cesare Pautasso
30
14
Measuring Effort Do-it-yourself Alternatives
REST 5
WS-* 0
Decisions with only do-it-yourself alternatives
19.6.2008
• •
Resource Identification Resource Relationship
• • •
Reliability Transactions Service Discovery University of Milano Bicocca, Italy ©2008 Cesare Pautasso
31
Freedom of Choice Freedom from Choice
19.6.2008
University of Milano Bicocca, Italy ©2008 Cesare Pautasso
32
15
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) 19.6.2008
University of Milano Bicocca, Italy ©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. 19.6.2008
University of Milano Bicocca, Italy ©2008 Cesare Pautasso
34
16
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. 19.6.2008
University of Milano Bicocca, Italy ©2008 Cesare Pautasso
35
17