RESTful Business Process Management example, most existing RESTful Web service APIs cannot natively...
Transcript of RESTful Business Process Management example, most existing RESTful Web service APIs cannot natively...
RESTful Business Process Management
Cesare PautassoFaculty of Informatics
University of Lugano, Switzerland
[email protected]://www.pautasso.info
©2010 - Cesare Pautasso 2
Abstract Next generation Web services technologies
challenge the assumptions made by current standards for process-based service composition. For example, most existing RESTful Web service APIs cannot natively be composed using the WS-BPEL standard.
In this talk we discuss the conceptual relationship between business processes and stateful resources with the goal of enabling lightweight access to service compositions published with a RESTful API. We show that the uniform interface and the hyper-linking capabilities of RESTful services provide an excellent abstraction for publishing as a resource and exposing in a controlled way the execution state of business processes.
©2010 - Cesare Pautasso 3
BPM REST
©2010 - Cesare Pautasso 4
BPMWorkflow
Languages
RESTfulWeb Services
©2010 - Cesare Pautasso 5
BPMWorkflow
Languages
Hypermedia
RESTfulService
Composition
©2010 Cesare Pautasso 6
• Assistant Professor at the Faculty of Informatics,University of Lugano, Switzerland (since Sept 2007)
• Research Projects:• SOSOA – Self-Organizing Service Oriented Architectures• CLAVOS – Continuous Lifelong Analysis and Verification
of Open Services• BPEL for REST
• Researcher at IBM Zurich Research Lab (2007)• Post-Doc at ETH Zürich
• Software:JOpera: Process Support for more than Web serviceshttp://www.jopera.org/
• Ph.D. at ETH Zürich, Switzerland (2004)
• Representations: http://www.pautasso.info/ (Web) http://twitter.com/pautasso/ (Twitter Feed)
About Cesare Pautasso
©2010 - Cesare Pautasso 7
WS-REST 2010
26 April 2010, Raleigh NC, USA World Wide Web 2010 Conference Keynote by Sam Ruby, Apache & IBM http://ws-rest.org/
©2010 - Cesare Pautasso 8
Raj Balasubramanian, Benjamin Carlyle, Thomas Erl, Cesare Pautasso, SOA with REST, Prentice Hall, to appear in 2010
©2010 - Cesare Pautasso 9
We believe there is huge potential to marrying REST with workflow and BPM.
[…]Combined with the architecture of the Web, a workflow service can provide both a truly simple, portable, and flexible way to build workflow driven integrations and applications.
From REST-*
http
://w
ww.
jbos
s.or
g/re
stst
ar/s
peci
ficat
ions
/wor
kflo
w.ht
ml“
”
©2010 - Cesare Pautasso 10
WS-BPEL Primitives
WebService<invoke>
WebService
<invoke>
<receive><reply>
<receive>
The workflow language natively supports the RPC or message-based connectors
©2010 - Cesare Pautasso 11
WS-BPEL Primitives
WebService<invoke>
WebService
<invoke>
<receive><reply>
<receive> Easy to map this to HTTP!
©2010 - Cesare Pautasso 12
WSDL 2.0 HTTP Binding can wrap RESTful Web Services
BPEL/WSDL 2.0
(WS-BPEL 2.0 does not support WSDL 2.0)
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
©2010 - Cesare Pautasso 13
RESTful APIs…
…do not use WSDL
©2010 - Cesare Pautasso 14
WS-BPEL Primitives
WebService<invoke>
WebService
<invoke>
<receive><reply>
<receive> Easy to map this to HTTP?
We need something else
©2010 - Cesare Pautasso 15
We believe there is huge potential to marrying REST with workflow and BPM. The HATEOAS (hypermedia and linking)
principal of REST is logically a dynamic state machine and fits very well with how workflow and BPM systems are designed. Combined with the architecture of the Web,
a workflow service can provide both a truly simple, portable, and flexible way to build workflow driven integrations and applications.
From REST-*
http
://w
ww.
jbos
s.or
g/re
stst
ar/s
peci
ficat
ions
/wor
kflo
w.ht
ml“
”
©2010 - Cesare Pautasso 16
RESTful BPM Challenges Can you drive the execution of tasks with
PUT/POST/DELETE requests? Can you monitor your processes with an
RSS/ATOM feed? Can you bookmark a process instance? Can you send an email to your colleague with a
link to a task from your worklist? Can you ask a process to give you links to its
tasks left to be done? Can you publish your process as a resource? Can you publish resources from your process? Can you call RESTful APIs directly?
©2010 - Cesare Pautasso 17
Outline
RESTful BPM Challenges and Opportunities RESTful Service Composition Example: DoodleMap Mashups with BPM Hypermedia with BPM Example: TinyRESTBucks Outlook
©2010 - Cesare Pautasso 18
Web Services expose their data and functionality trough resources identified by URI
Uniform Interface Principle: Clients interact with resources through a fix set of verbs. Example HTTP:GET (read), POST (create), PUT (update), DELETE
Multiple representations for the same resource Hyperlinks model resource relationships and valid
state transitions for dynamic protocol description and discovery
REST in one slide
RPUT
DELETE
GET
POST
©2010 - Cesare Pautasso 19
REST Scalability
Origin ServerClient
Proxy/Gateway
One example of REST middleware is to help with the scalability of a server, which may need to service a very large number of clients
Cache
Clients
©2010 - Cesare Pautasso 20
REST Scalability
Origin Server
Clients
Proxy/Gateway
One example of REST middleware is to help with the scalability of a server, which may need to service a very large number of clients
Cache
©2010 - Cesare Pautasso 21
REST Composition
Origin Server
Clients
Proxy/Gateway
Composition shifts the attention to the client which should consume and aggregate from many servers
©2010 - Cesare Pautasso 22
Servers
REST Composition
Origin Client
The “proxy” intermediate element which aggregates the resources provided by multiple servers plays the role of a composite RESTful service Can/Should we implement it with BPM?
CompositeRESTfulservice
©2010 - Cesare Pautasso 23
Composite Resources
PUT
DELETE
GET
POST
PUT
DELETE
GET
POST
C
RPUT
DELETE
GET
POST
S
©2010 - Cesare Pautasso 24
Composite Resources
StateR
StateS
C
R S
The composite resource only aggregates the state of its component resources
©2010 - Cesare Pautasso 25
Composite Resources
StateR
StateS
StateC
C
R S
The composite resource augments (or caches) the state of its component resources
©2010 - Cesare Pautasso 26
Web Services expose their data and functionality trough resources identified by URI
Uniform Interface Principle: Clients interact with resources through a fix set of verbs. Example HTTP:GET (read), POST (create), PUT (update), DELETE
Multiple representations for the same resource Hyperlinks model resource relationships and valid
state transitions for dynamic protocol description and discovery
Enter HATEOAS
RPUT
DELETE
GET
POST
©2010 - Cesare Pautasso 27
Composite Representations
PUT
PUT
DELETE
DELETE
GET
GETPOST
POSTC
RS
LinkR
LinkS
Composite Representation
©2010 - Cesare Pautasso 28
Composite Representation
CompositeRepresentation
Origin Servers
Client
OriginServer
A composite representation is interpreted by the client that follows its hyperlinks and aggregates the state of the referenced component resources
©2010 - Cesare Pautasso 29
Bringing it all together
CompositeRepresentation
Origin Servers
Client
CompositeRESTfulservice
A composite representation can be produced by a composite service too
Origin Servers
©2010 - Cesare Pautasso 30
Doodle Map Example
CompositeRepresentation
Origin Servers
Client
CompositeRESTfulservice
Vote on a meeting place based on its geographic location
Origin Servers
©2010 - Cesare Pautasso 31
1. Composite Resource
PUT
DELETE
GET
POST
PUT
DELETE
GET
POST
C
RPUT
DELETE
GET
POST
S
©2010 - Cesare Pautasso 32
1. Composite Resource
GET
DELETE
GET
POST
C
RPUT
DELETE
GET
POST
S
©2010 - Cesare Pautasso 33
2. Composite Representation
GET
DELETE
GET
POST
C
RPUT
DELETE
GET
POST
S
DMLinkG
LinkC
GETG
LinkD
©2010 - Cesare Pautasso 34
Demo
DoodleMap with JOpera
©2010 - Cesare Pautasso 35
DoodleMap Workflow
©2010 - Cesare Pautasso 36
Viewpoints
DataFlow
ControlFlow
ServiceBindings
HTTPXPATH XSLTJAVA HTML …
©2010 - Cesare Pautasso 37
ControlFlow
Control FlowDependency
©2010 - Cesare Pautasso 38
ServiceBindings
HTTP
XPATH
XSLT
JAVA
HTML
…
©2010 - Cesare Pautasso 39
DataFlow
Data Flow(Copy)
©2010 - Cesare Pautasso 40
BPM for Mashups?
MashupREST
Composition
Mashup
(It depends on the definition of Mashup)
©2010 - Cesare Pautasso 41
Read-only vs. Read/Write
Moving state around
PUT
DELETE
GET
POST
PUT
DELETE
GET
POST
C
RPUT
DELETE
GET
POST
S
©2010 - Cesare Pautasso 42
Read-only vs. Read/write
Simply aggregating data (feeds)
GET
GETC
RGET
S
©2010 - Cesare Pautasso 43
UI vs. API Composition
Is your composition reusable?
CompositeRepresentation
Origin Servers
Client
CompositeRESTfulservice
Origin Servers
API
UI Reusable services vs. Reusable Widgets
©2010 - Cesare Pautasso 44
Can you always do thisfrom a web browser?
Single-Origin Sandbox
Client
CompositeRESTfulservice
Origin Servers
Origin Servers
CompositeRepresentation
©2010 - Cesare Pautasso 45
Security Policies on the client may not always allow it to aggregate data from multiple different sources
Single-Origin Sandbox
CompositeRepresentation
Client
CompositeRESTfulservice
N Origin Servers
1 Origin Server
©2010 - Cesare Pautasso 46
Complementary
Mashup RESTComposition
Mashup
Read-OnlyRead/Write
APIUI
SituationalReusable
ServiceSandboxed
©2010 - Cesare Pautasso 47
TinyRESTBucks Example
/rest/restbucks/order/1.0/{id}
/tasks/restbucks/order/1.0/{id}/payment
/receipt/{uuid}
/rest/restbucks/order/1.0/ POST
POST
GET
GET
©2010 - Cesare Pautasso 48
Instantiating a process
GET /rest/restbucks/order/1.0/
©2010 - Cesare Pautasso 49
Interacting with a task
GET /rest/restbucks/order/1.0/0/payment
©2010 - Cesare Pautasso 50
Interacting with a task
POST /rest/restbucks/order/1.0/0/payment
©2010 - Cesare Pautasso 51
Interacting with a resource
GET /receipt/2fc7f6e2-8b43-4672-a7c4…
©2010 - Cesare Pautasso 52
Interacting with a resource
DELETE /rest/restbucks/order/1.0/0
©2010 - Cesare Pautasso 53
Deleting a process resource
DELETE /rest/restbucks/order/1.0/0
©2010 - Cesare Pautasso 54
ServiceBindings
SQL
REST.URI
REST
REST.TASK
WS-*
©2010 - Cesare Pautasso 55
DataFlow
Data Flow(Copy)
©2010 - Cesare Pautasso 56
1. Abstract Workflow Service invocation technology does not matter
2. Concrete Workflow Expose service invocation
technologies as explicit constructsin the workflow language
3. RESTful Workflow Workflow as one kind of resource
exposed by a RESTful service
Solution SpaceBPM
WorkflowLanguages
RESTfulWeb ServiceComposition
BPMWorkflow
Languages
RESTfulWeb ServiceComposition
BPMWorkflow
Languages
RESTfulWeb ServiceComposition
©2010 - Cesare Pautasso 57
RESTful HTTP is good enough to interact without any extension with process execution engines and their processes and tasks published as resources
RESTful Web service composition is different than mashups, but both can be built using BPM
If done right, BPM can be a great modeling tool for Hypermedia-centric service design(and implementation!)
GET http://www.jopera.org/
Conclusions
© 58
R. Fielding, Architectural Styles and the Design of Network-based Software 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. Pautasso, BPEL for REST, Proc. of the 7th International Conference on Business Process Management (BPM 2008), Milano, Italy, September 2008
C. Pautasso, Composing RESTful Services with JOpera,In: Proc. of the International Conference on Software Composition (SC2009), July 2009, Zurich, Switzerland.
References