RESTful Web Service Composition: putting BPEL to REST
Transcript of RESTful Web Service Composition: putting BPEL to REST
![Page 1: RESTful Web Service Composition: putting BPEL to REST](https://reader035.fdocuments.in/reader035/viewer/2022071602/613d5841736caf36b75c3960/html5/thumbnails/1.jpg)
19 October 2008 ©2008 Cesare Pautasso | www.pautasso.info
RESTful Web Service Composition:putting BPEL to REST
Cesare PautassoFaculty of Informatics
University of Lugano (USI), Switzerlandhttp://www.pautasso.info
![Page 2: RESTful Web Service Composition: putting BPEL to REST](https://reader035.fdocuments.in/reader035/viewer/2022071602/613d5841736caf36b75c3960/html5/thumbnails/2.jpg)
©2008 Cesare Pautasso2
• Faculty of Informatics (Opened 2004)• 15 Professors• 63 PhD + Post-doc
• Excellence in Research• Innovative Teaching
University of Lugano, Switzerland
![Page 3: RESTful Web Service Composition: putting BPEL to REST](https://reader035.fdocuments.in/reader035/viewer/2022071602/613d5841736caf36b75c3960/html5/thumbnails/3.jpg)
©2008 Cesare Pautasso3
My Research Interests
Web 2.0Mashups
BusinessProcess
Management
AutonomicComputing
ScientificWorkflow
Management
ServiceOriented
Architectures
SoftwareComposition
CesarePautasso
![Page 4: RESTful Web Service Composition: putting BPEL to REST](https://reader035.fdocuments.in/reader035/viewer/2022071602/613d5841736caf36b75c3960/html5/thumbnails/4.jpg)
49 October 2008 ©2008 Cesare Pautasso | www.pautasso.info
RESTful Web Service Composition:putting BPEL to REST
Cesare PautassoFaculty of Informatics
University of Lugano (USI), Switzerlandhttp://www.pautasso.info
![Page 5: RESTful Web Service Composition: putting BPEL to REST](https://reader035.fdocuments.in/reader035/viewer/2022071602/613d5841736caf36b75c3960/html5/thumbnails/5.jpg)
59 October 2008 ©2008 Cesare Pautasso | www.pautasso.info
The WS-BPEL process model is layered on top of the service model defined by WSDL 1.1. […] Both the process and its partners are exposed as WSDL services
[BPEL 2.0 Standard, Section 3]
Motivation – Why BPEL for REST?
WSDL 1.1
WS-BPEL 2.0
![Page 6: RESTful Web Service Composition: putting BPEL to REST](https://reader035.fdocuments.in/reader035/viewer/2022071602/613d5841736caf36b75c3960/html5/thumbnails/6.jpg)
69 October 2008 ©2008 Cesare Pautasso | www.pautasso.info
RESTful Web Services APIs…
WSDL 1.1
…do not use WSDL 1.1
![Page 7: RESTful Web Service Composition: putting BPEL to REST](https://reader035.fdocuments.in/reader035/viewer/2022071602/613d5841736caf36b75c3960/html5/thumbnails/7.jpg)
79 October 2008 ©2008 Cesare Pautasso | www.pautasso.info
Compose RESTful Web Services
Compose WSDL Web Services
Use Business Process Modeling Languages
The Goal
Extend BPEL to support RESTful Web Services
One Solution: BPEL for REST
![Page 8: RESTful Web Service Composition: putting BPEL to REST](https://reader035.fdocuments.in/reader035/viewer/2022071602/613d5841736caf36b75c3960/html5/thumbnails/8.jpg)
89 October 2008 ©2008 Cesare Pautasso | www.pautasso.info
Web Sites (1992)
HTTP
HTMLWeb Browser
Web Server
(HTTP)
SOAP
ServerClient XMLWSDL
WS-* Web Services (2000)
![Page 9: RESTful Web Service Composition: putting BPEL to REST](https://reader035.fdocuments.in/reader035/viewer/2022071602/613d5841736caf36b75c3960/html5/thumbnails/9.jpg)
99 October 2008 ©2008 Cesare Pautasso | www.pautasso.info
RESTful Web Services (2007)
Client HTTP
PO-XM
L
RSS
JSON
Web Server
WADL
(HTTP)
SOAP
ServerClient XMLWSDL
WS-* Web Services (2000)
![Page 10: RESTful Web Service Composition: putting BPEL to REST](https://reader035.fdocuments.in/reader035/viewer/2022071602/613d5841736caf36b75c3960/html5/thumbnails/10.jpg)
109 October 2008 ©2008 Cesare Pautasso | www.pautasso.info
File Transfer
Shared Data
Remote Procedure CallMessage Bus
Events
Stream
REpresentationalState Transfer
Application Integration Styles vs. REST
![Page 11: RESTful Web Service Composition: putting BPEL to REST](https://reader035.fdocuments.in/reader035/viewer/2022071602/613d5841736caf36b75c3960/html5/thumbnails/11.jpg)
119 October 2008 ©2008 Cesare Pautasso | www.pautasso.info
Web Services expose their data and functionality trough resources identified by URI
Uniform Interface Principle: Clients interact with the state of resources through 4 verbs: GET (read), POST (create), PUT (update), DELETE
Multiple representations for the same resource
Hyperlinks model resource relationships and valid state transitions
REST in one slide
R
PUT
DELETE
GET
POST
![Page 12: RESTful Web Service Composition: putting BPEL to REST](https://reader035.fdocuments.in/reader035/viewer/2022071602/613d5841736caf36b75c3960/html5/thumbnails/12.jpg)
129 October 2008 ©2008 Cesare Pautasso | www.pautasso.info
Resource addressing through URIInteract with dynamic, variable set of URI
Uniform Interface (GET, POST, PUT, DELETE)Make the 4 verbs explicit in the composition language
Multiple resource representationsNo static message types Negotiate with clients the most appropriate representation
HyperlinksImplement state transition logic of a resourceGenerate new URIs dynamically as processes runs
The Challenges
![Page 13: RESTful Web Service Composition: putting BPEL to REST](https://reader035.fdocuments.in/reader035/viewer/2022071602/613d5841736caf36b75c3960/html5/thumbnails/13.jpg)
139 October 2008 ©2008 Cesare Pautasso | www.pautasso.info
WSDL 2.0 HTTP Binding can wrap RESTful Web Services
The Hack – Without BPEL for REST
R
WSDL 2.0BPEL PUT
DELETE
GET
POST
Operations
HTTP Binding
Op_1Op_2Op_3Op_4
...
<Invoke Op_1>
<Invoke Op_2>
...
<Invoke Op_3>
<Invoke Op_4>
...
Op_1 R PUTOp_2 R GETOp_3 R POSTOp_4 R DELETE
Op URI Method
R PUTR GETR POSTR DELETE
(WS-BPEL 2.0 does not support WSDL 2.0)
![Page 14: RESTful Web Service Composition: putting BPEL to REST](https://reader035.fdocuments.in/reader035/viewer/2022071602/613d5841736caf36b75c3960/html5/thumbnails/14.jpg)
149 October 2008 ©2008 Cesare Pautasso | www.pautasso.info
Native support for direct invocation of RESTful Web services
REST concepts first-class language constructs
BPEL for REST
R
BPEL for REST PUT
DELETE
GET
POST
...
<Put R>
<Get R>
...
<Post R>
<Delete R>
...
<Put R>
<Get R>
<Post R>
<Delete R>
![Page 15: RESTful Web Service Composition: putting BPEL to REST](https://reader035.fdocuments.in/reader035/viewer/2022071602/613d5841736caf36b75c3960/html5/thumbnails/15.jpg)
159 October 2008 ©2008 Cesare Pautasso | www.pautasso.info
Motivation
BPEL for REST ExtensionsInvoking RESTful Web Services
Publishing RESTful Web Services
Example
Outlook
Agenda – BPEL for REST
![Page 16: RESTful Web Service Composition: putting BPEL to REST](https://reader035.fdocuments.in/reader035/viewer/2022071602/613d5841736caf36b75c3960/html5/thumbnails/16.jpg)
169 October 2008 ©2008 Cesare Pautasso | www.pautasso.info
BPEL for REST - invocation primitives
WebService<invoke>
WebService
<invoke>
<receive><reply>
<receive>
R esource
PUT
DELETE
GET
POST
<put><get><post><delete>
<onPut><onGet><onPost>
<onDelete>
![Page 17: RESTful Web Service Composition: putting BPEL to REST](https://reader035.fdocuments.in/reader035/viewer/2022071602/613d5841736caf36b75c3960/html5/thumbnails/17.jpg)
179 October 2008 ©2008 Cesare Pautasso | www.pautasso.info
<get uri="" response="">
<header name="">*value</header>
<catch code="" faultName=""?>*...</catch>
<catchAll>?...</catchAll>
</get>
<post uri="" request="" response=""> ... </post>
<put uri="" request="" response=""?> </put>
Invoking RESTful Web Services4 new activities (get, post, put, delete)
![Page 18: RESTful Web Service Composition: putting BPEL to REST](https://reader035.fdocuments.in/reader035/viewer/2022071602/613d5841736caf36b75c3960/html5/thumbnails/18.jpg)
189 October 2008 ©2008 Cesare Pautasso | www.pautasso.info
<resource uri="">
<variable>*
<onGet>? ... </onGet>
<onPut>? ... </onPut>
<onDelete>? ... </onDelete>
<onPost isolated="false"?>? </onPost>
Publishing RESTful Web Services - I4 new request handlers (onGet, onPut, onDelete, onPost)
1 new “scope” (resource)
![Page 19: RESTful Web Service Composition: putting BPEL to REST](https://reader035.fdocuments.in/reader035/viewer/2022071602/613d5841736caf36b75c3960/html5/thumbnails/19.jpg)
199 October 2008 ©2008 Cesare Pautasso | www.pautasso.info
<response code=""?>
<header name="">*value</header>
payload
</response>
Publishing RESTful Web Services - II1 new activity (response)
![Page 20: RESTful Web Service Composition: putting BPEL to REST](https://reader035.fdocuments.in/reader035/viewer/2022071602/613d5841736caf36b75c3960/html5/thumbnails/20.jpg)
209 October 2008 ©2008 Cesare Pautasso | www.pautasso.info
Example
Loan Application Service Process
ClientLoan
Service(BPEL)
POST /loan
GET /loan
DELETE /loan
GET /rate
POST $accept
GET /loan/choice
PUT /loan/choiceBank
Services
![Page 21: RESTful Web Service Composition: putting BPEL to REST](https://reader035.fdocuments.in/reader035/viewer/2022071602/613d5841736caf36b75c3960/html5/thumbnails/21.jpg)
219 October 2008 ©2008 Cesare Pautasso | www.pautasso.info
<process name="LoanApplication"><resource uri="loan">
<!-- State variables of the resource --><variable name="name"/><variable name="amount"/><variable name="rate"/><variable name="bank"/><variable name="start_date"/><variable name="end_date"/>
1. State of the ResourceDeclarative construct to publish a resource URI
![Page 22: RESTful Web Service Composition: putting BPEL to REST](https://reader035.fdocuments.in/reader035/viewer/2022071602/613d5841736caf36b75c3960/html5/thumbnails/22.jpg)
229 October 2008 ©2008 Cesare Pautasso | www.pautasso.info
<onPost><if>
<condition>$request.amount > 100000</condition><then>
<respond code="400">Requested amount too large
</respond><exit/>
</then>
2. Handle POST request - PreconditionsCreate a new loan application resources only if…
![Page 23: RESTful Web Service Composition: putting BPEL to REST](https://reader035.fdocuments.in/reader035/viewer/2022071602/613d5841736caf36b75c3960/html5/thumbnails/23.jpg)
239 October 2008 ©2008 Cesare Pautasso | www.pautasso.info
<else><sequence><assign>
name = $request.name;amount = $request.amount;start_date = $request.start_date;
</assign><respond code="201">
<header name=“Location”>/loan/$name</header>Processing loan application…
</respond>
3. Handle POST request - InitializationStore initial loan application resource state
![Page 24: RESTful Web Service Composition: putting BPEL to REST](https://reader035.fdocuments.in/reader035/viewer/2022071602/613d5841736caf36b75c3960/html5/thumbnails/24.jpg)
249 October 2008 ©2008 Cesare Pautasso | www.pautasso.info
<scope><variable name="ubs_response"/>
<variable name="cs_response"/>
<variable name="url_accept"/><variable name="accept_response"/>
<flow>
<geturi="http://www.ubs.ch/rate?chf=$amount&from=$start_date"
response="ubs_response">
<geturi="http://www.cs.ch/rates?amount=$amount&start=$start_date"
response="cs_response">
</flow>
4. Invoke RESTful Web ServicesGet rates from banks
![Page 25: RESTful Web Service Composition: putting BPEL to REST](https://reader035.fdocuments.in/reader035/viewer/2022071602/613d5841736caf36b75c3960/html5/thumbnails/25.jpg)
259 October 2008 ©2008 Cesare Pautasso | www.pautasso.info
<while><condition>TRUE</condition>
<resource uri="choice">
<onGet><respond code="200">
<header name="Content-Type">application/json</header>
[ { bank:"cs",rate:"$cs_response.rate",
end_date:"$cs_response.until" },
{ bank:"ubs",rate:"$ubs_response.rate",
end_date:"$ubs_response.end" } ]
</respond></onGet>
5. Let Client Choose – GET HandlerReturn rates offered by the banks
![Page 26: RESTful Web Service Composition: putting BPEL to REST](https://reader035.fdocuments.in/reader035/viewer/2022071602/613d5841736caf36b75c3960/html5/thumbnails/26.jpg)
269 October 2008 ©2008 Cesare Pautasso | www.pautasso.info
<onPost><sequence><assign>bank = $request.choice;</assign>
<if>
<condition>bank == "cs"</condition><then>
<assign>rate = $cs_response.rate;
end_date = $cs_response.until;url_accept = $cs_response.accept</assign></then>
<else><assign>rate = $ubs_response.rate;
end_date = $ubs_response.end;url_accept = $ubs_response.accept</assign></else>
</if>
<respond code="200"/><activeBPEL:break/></sequence></onPost></resource></while>
6. Let Client Choose – POST HandlerStore the client choice and continue
![Page 27: RESTful Web Service Composition: putting BPEL to REST](https://reader035.fdocuments.in/reader035/viewer/2022071602/613d5841736caf36b75c3960/html5/thumbnails/27.jpg)
279 October 2008 ©2008 Cesare Pautasso | www.pautasso.info
<post uri="$url_accept" request="$name"
response="accept_response">
</scope>
</sequence>
</else>
</if>
</onPost>
7. Inform BankAccept the loan offered by the chosen bank
![Page 28: RESTful Web Service Composition: putting BPEL to REST](https://reader035.fdocuments.in/reader035/viewer/2022071602/613d5841736caf36b75c3960/html5/thumbnails/28.jpg)
289 October 2008 ©2008 Cesare Pautasso | www.pautasso.info
<onDelete>
<if><condition>bank == null</condition>
<then>
<respond code="200"/><exit/>
</then>
<else><!-- Start the loan cancellation process -->
<invoke...>
</else></if>
</onDelete>
8. Let Client Choose – DELETE HandlerCancel the loan application or cancel the loan
![Page 29: RESTful Web Service Composition: putting BPEL to REST](https://reader035.fdocuments.in/reader035/viewer/2022071602/613d5841736caf36b75c3960/html5/thumbnails/29.jpg)
299 October 2008 ©2008 Cesare Pautasso | www.pautasso.info
BPEL for REST Extensions - SummaryPublishing and Invoking RESTful Web Services
BPEL for REST
<Resource P>
<onGet>
<Put R>
<Get S>
</onGet>
<Post R>
<Delete S>
</onDelete>
</Resource>
<onDelete>
R
PUT
DELETE
GET
POST
S
PUT
DELETE
GET
POST
P
PUT
DELETE
GET
POST
![Page 30: RESTful Web Service Composition: putting BPEL to REST](https://reader035.fdocuments.in/reader035/viewer/2022071602/613d5841736caf36b75c3960/html5/thumbnails/30.jpg)
309 October 2008 ©2008 Cesare Pautasso | www.pautasso.info
Mapping the Stateof Resources and Processes
P
R
PUT
DELETE
GET
POST
R
PUT
DELETE
GET
POST
Correlation
Lifecycle
Visibility
Access Control
![Page 31: RESTful Web Service Composition: putting BPEL to REST](https://reader035.fdocuments.in/reader035/viewer/2022071602/613d5841736caf36b75c3960/html5/thumbnails/31.jpg)
319 October 2008 ©2008 Cesare Pautasso | www.pautasso.info
Reference Architecture
BPEL Engine
BPEL for REST Engine
ProcessExecution
Front-End Back-End
Resource P
ublisherS
ervlet
HTTP
Server
RES
T fulInvocation A
ctivities
HTTP C
lientPersistentExecution
State
![Page 32: RESTful Web Service Composition: putting BPEL to REST](https://reader035.fdocuments.in/reader035/viewer/2022071602/613d5841736caf36b75c3960/html5/thumbnails/32.jpg)
329 October 2008 ©2008 Cesare Pautasso | www.pautasso.info
Business Process Modeling Languages have been applied with success to compose “traditional” WS-* Web Services (BPM = SOA + BPEL)
Business Process Modeling Languages should also be applied to compose RESTful Web Services
BPEL for REST is a lightweight WS-BPEL extension for composing both kinds of services
Conclusion
![Page 33: RESTful Web Service Composition: putting BPEL to REST](https://reader035.fdocuments.in/reader035/viewer/2022071602/613d5841736caf36b75c3960/html5/thumbnails/33.jpg)
339 October 2008 ©2008 Cesare Pautasso | www.pautasso.info
R. Fielding, Architectural Stylesand the Design of Network-basedSoftware Architectures, PhD Thesis, University of California, Irvine, 2000
C. Pautasso, O. Zimmermann, F. 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.
C. Pautaso, BPEL for REST, Proc. of the 7th International Conference on Business Process Management (BPM 2008), Milano, Italy, September 2008.
More information
R
PUT
DELETE
GET
POST
![Page 34: RESTful Web Service Composition: putting BPEL to REST](https://reader035.fdocuments.in/reader035/viewer/2022071602/613d5841736caf36b75c3960/html5/thumbnails/34.jpg)
©2008 Cesare Pautasso34
PhD positions available!
Prof. Cesare PautassoUniversity of Lugano, Switzerland
[email protected]://www.pautasso.info