Composing REST Services

26
1 6 January 2009 ©2009 Cesare Pautasso | www.pautasso.info Composing REST Services Open Dagstuhl Session Cesare Pautasso Faculty of Informatics University of Lugano (USI), Switzerland http://www.pautasso.info

Transcript of Composing REST Services

Page 1: Composing REST Services

16 January 2009 ©2009 Cesare Pautasso | www.pautasso.info

Composing REST ServicesOpen Dagstuhl Session

Cesare PautassoFaculty of Informatics

University of Lugano (USI), Switzerlandhttp://www.pautasso.info

Page 2: Composing REST Services

26 January 2009 ©2009 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]

Web Service Composition Today

WSDL 1.1

WS-BPEL 2.0

Page 3: Composing REST Services

36 January 2009 ©2009 Cesare Pautasso | www.pautasso.info

RESTful Web Services APIs…

WSDL 1.1

…do not use WSDL 1.1

Page 4: Composing REST Services

46 January 2009 ©2009 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 5: Composing REST Services

56 January 2009 ©2009 Cesare Pautasso | www.pautasso.info

Compose RESTful Web Services

Compose WSDL Web Services

Use Business Process Modeling Languages

The Goal

Visual Flow Language with Abstract Service Model

Extensible Autonomic Engine Architecture

Another Solution: JOpera

Page 6: Composing REST Services

66 January 2009 ©2009 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 7: Composing REST Services

76 January 2009 ©2009 Cesare Pautasso | www.pautasso.info

Resource addressing through URIHow to interact with dynamic, variable set of URI?

Uniform Interface (GET, POST, PUT, DELETE)Does it help to make the verbs explicit in the workflow?

Multiple resource representationsHow to negotiate the most appropriate representation?

HyperlinksCan the workflow implement state transition logic of a resource and generate new URIs dynamically as processes run to guide the clients invoking them?

Challenges for Composition Languages

Page 8: Composing REST Services

86 January 2009 ©2009 Cesare Pautasso | www.pautasso.info

JOpera Example: Doodle Map MashupSetup a Doodle with Yahoo! Local search and visualize the results of the poll on Google Maps

Page 9: Composing REST Services

96 January 2009 ©2009 Cesare Pautasso | www.pautasso.info

Doodle Map Mashup Architecture

Web Browser WorkflowEngine

RESTfulWeb Services

APIsGET

POST

GET

RES

Tful

API

Page 10: Composing REST Services

106 January 2009 ©2009 Cesare Pautasso | www.pautasso.info

Page 11: Composing REST Services

116 January 2009 ©2009 Cesare Pautasso | www.pautasso.info

BPMWorkflow

Languages

RESTfulWeb ServiceComposition

Page 12: Composing REST Services

126 January 2009 ©2009 Cesare Pautasso | www.pautasso.info

1. Abstract WorkflowService invocation technology does not matter

2. Concrete WorkflowExpose service invocation technologies as explicit constructsin the workflow language

3. RESTful WorkflowWorkflow as one kind of resource exposed by a RESTful service

Solution Space BPMWorkflow

Languages

RESTfulWeb ServiceComposition

BPMWorkflow

Languages

RESTfulWeb ServiceComposition

BPMWorkflow

Languages

RESTfulWeb ServiceComposition

Page 13: Composing REST Services

136 January 2009 ©2009 Cesare Pautasso | www.pautasso.info

WSDL 2.0 HTTP Binding can wrap RESTful Web Services

1. Abstract Workflow Example: BPEL/WSDL

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: Composing REST Services

146 January 2009 ©2009 Cesare Pautasso | www.pautasso.info

Idea: Make REST interaction primitives first-class language constructs

2. Concrete Workflow: 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: Composing REST Services

156 January 2009 ©2009 Cesare Pautasso | www.pautasso.info

BPEL for REST – New Activities/Handlers

WebService<invoke>

WebService

<invoke>

<receive><reply>

<receive>

R esource

PUT

DELETE

GET

POST

<put><get><post><delete>

<onPut><onGet><onPost>

<onDelete>

Page 16: Composing REST Services

166 January 2009 ©2009 Cesare Pautasso | www.pautasso.info

Dynamically publish resources from BPEL processes and handle client requests

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

BPEL for REST – Resource Block

Page 17: Composing REST Services

176 January 2009 ©2009 Cesare Pautasso | www.pautasso.info

3. RESTful WorkflowsP

R

PUT

DELETE

GET

POST

R

PUT

DELETE

GET

POST

Use the resource interface abstraction to publish the state of the workflow

Page 18: Composing REST Services

186 January 2009 ©2009 Cesare Pautasso | www.pautasso.info

Publish workflows as resources identified by the URIs:

/package/process

/package/process/version

/package/process/version/instance

/package/process/version/instance/task

/package/process/version/instance/task/parameter

Workflows as Resources – URI

Page 19: Composing REST Services

196 January 2009 ©2009 Cesare Pautasso | www.pautasso.info

GET /package/processEnumerate deployed process versions

GET /package/process/versionEnumerate active instances of a given process version

GET /package/process/version/instanceRead the current state of a workflow instance

GET /package/process/version/instance/taskRead the current state of a workflow instance task

GET /package/process/version/instance/task/paramRead the current value of a workflow instance parameter

Reading the state of the workflow resources

Page 20: Composing REST Services

206 January 2009 ©2009 Cesare Pautasso | www.pautasso.info

POST /packageDeploy new process template into package

POST /package/processDeploy new version of a process

POST /package/process/versionCreate new process instance

Creating new workflow resources

Page 21: Composing REST Services

216 January 2009 ©2009 Cesare Pautasso | www.pautasso.info

PUT /package/process/version/instance/taskUpdate the state of a workflow task (e.g., finished, failed)

PUT /package/process/version/instance/task/paramWrite into task parameters some values

Updating the workflow resource

Page 22: Composing REST Services

226 January 2009 ©2009 Cesare Pautasso | www.pautasso.info

DELETE /package/processUndeploy all versions of a process (and all the corresponding process instances)

DELETE /package/process/versionUndeploy a version of a process (and all of its instances)

DELETE /package/process/version/instanceRemove the state of a specific process instance only

Deleting workflow resources

Page 23: Composing REST Services

236 January 2009 ©2009 Cesare Pautasso | www.pautasso.info

Why should a workflow engine care about REST? Use workflows to compose RESTful Web services

Implement RESTful services with a workflow

Should a process explicitly include RESTful activities?Or it is better/enough to model REST implicitly?

How much of the state of a process instance should be exposed as a resource?

How to control which “parts” are visible?

Discussion

Page 24: Composing REST Services

246 January 2009 ©2009 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 ServicesBPEL for REST is a lightweight BPEL extension for REST and WS-* service compositionJOpera for Eclipse is a visual process modeling tool with an extensible engine for composing both kinds of services (and many more)

Conclusion

Page 25: Composing REST Services

256 January 2009 ©2009 Cesare Pautasso | www.pautasso.info

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

Xiwei (Sherry) Xu, Liming Zhu, Yan Liu, Mark Staples, Resource-Oriented Architecture for Business Processes, APSEC’08

Some References

Page 26: Composing REST Services

©2008 Cesare Pautasso26

PhD positions available!

Prof. Cesare PautassoUniversity of Lugano, Switzerland

[email protected]://www.pautasso.info