RESTful Service Composition
with JOpera
Cesare Pautasso
Faculty of Informatics, USI Lugano, Switzerland
c.pautasso@ieee.or...
Abstract
             Next generation Web services technologies challenge the
             assumptions made by current sta...
From REST-*



       “     We believe there is huge potential to
          marrying REST with workflow and BPM.




     ...
WS-BPEL Primitives

                             Web       <receive>
            <invoke>
                             Ser...
WS-BPEL Primitives

                             Web       <receive>
            <invoke>
                             Ser...
BPEL and WSDL 2.0
           WSDL 2.0 HTTP Binding can wrap RESTful Web Services
          (WS-BPEL 2.0 does not support W...
RESTful APIs…

                          …do
                           not
                           use
               ...
WS-BPEL Primitives

                             Web       <receive>
            <invoke>
                             Ser...
From REST-*



       “   We believe there is huge potential to
       marrying REST with workflow and BPM.




          ...
Outline
   1. Introduction
      to RESTful Web Services
   2. Defining
      RESTful Service Composition
   3. JOpera Dem...
REST in one slide
  Web Services expose their
   data and functionality trough      PUT
   resources identified by URI
  ...
Design Methodology
   1. Identify resources to be exposed as
      services (e.g., yearly risk report, book




          ...
Design Space
                                           M Representations (Variable)




©2009-2010 - Cesare Pautasso, Eri...
Simple Doodle API Example
   1. Resources:




                                                                           ...
Simple Doodle API Example
  1.        Creating a poll
            (transfer the state of a new poll on the Doodle service)...
Simple Doodle API Example
   Participating in a poll by creating a new vote sub-resource
                                ...
Simple Doodle API Example
   Existing votes can be updated (access control headers not shown)
                           ...
Simple Doodle API Example
   Polls can be deleted once a decision has been made
                                         ...
Real Doodle Demo
  • Info on the real Doodle API:
  http://doodle.com/xsd1/RESTfulDoodle.pdf
  • Lightweight demo with Pos...
Different software connectors

                          RPC         ESB



                                WWW



©2010 -...
REST Architectural Elements
      Client/Server                        Layered     Stateless Communication   Cache




   ...
Basic Setup
                                                        HTTP

                                           User ...
Proxy or Gateway?
Intermediaries forward (and may translate) requests and responses


                                    ...
What about composition?
    The basic REST design     WS-BPEL is the standard
     elements do not take       Web servic...
REST Scalability


                                       Cache


                                    Proxy/Gateway   Orig...
REST Composition




                                    Proxy/Gateway   Origin
                                          ...
REST Composition



              Client      Composite       Origin
                          RESTful        Servers
    ...
Composite Resources

                                DELETE
                          PUT


                          GET
...
Composite Resources
   The composite resource only aggregates the
    state of its component resources


                ...
Composite Resources
   The composite resource augments (or caches)
    the state of its component resources


           ...
Composite Representation
                                    DELETE
                                  PUT
                ...
Composite Representation
                               Composite
                               Representation
          ...
Bringing it all together

                    Composite
                    Representation
                               ...
Doodle Map Example

                    Composite
                    Representation
                                     ...
Composite Resource

                                DELETE
                          PUT


                          GET
 ...
Composite Resource

                                DELETE



                          GET
                              ...
Composite Representation


         DM                     DELETE
                                           GET
         ...
Demo




©2009-2010 - Cesare Pautasso, Erik Wilde   38
Doodle Map Architecture
        Web Browser                                      Workflow            RESTful
             ...
DoodleMap Model




©2010 - Cesare Pautasso   40
Viewpoints



                          Control        Data
                          Flow           Flow
                ...
Control
       Flow




           Control Flow
           Dependency



©2010 - Cesare Pautasso   42
Service
   Bindings


        HTTP

        HTML

       XSLT

       XPATH

       JAVA

       …
©2010 - Cesare Pautasso...
Data
      Flow




                Data Flow
                (Copy)



©2010 - Cesare Pautasso     44
Was it just a mashup?




                          Mashup
                                  REST
                        ...
Moving state around
      Read-only vs. Read/Write
                                DELETE
                          PUT

...
Simply aggregating data
      Read-only vs. Read/write




                          GET
                                ...
Is your composition reusable?
      UI vs. API Composition


                    Composite
                              ...
Single-Origin Sandbox
      Can you always do this
       from a web browser?

                    Composite
            ...
Single-Origin Sandbox
      Security Policies on the client may not
       always allow it to aggregate data from
       ...
Complementary
   Read-Only
                                          Read/Write


        UI                Mashup
       ...
Conclusions
      REST brings a new perspective and new
       problems to service composition
      RESTful services ca...
References
    Roy Fielding, Architectural Styles and the Design of Network-based
      Software Architectures, PhD Thesi...
Self-References
    Cesare Pautasso, Olaf Zimmermann, Frank Leymann,
     RESTful Web Services vs. Big Web Services: Maki...
Leonard Richardson,              Raj Balasubramanians, Benjamin
          Sam Ruby,                        Carlyle,Thomas ...
Abstract Submission: Friday, July 16, 2010
©2009-2010 - Cesare Pautasso, Erik Wilde                       56
Upcoming SlideShare
Loading in...5
×

RESTful Service Composition with JOpera

2,602

Published on

21.5.2010 Seminar at Politecnico di Milano, Italy

Published in: Technology
1 Comment
1 Like
Statistics
Notes
No Downloads
Views
Total Views
2,602
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
1
Likes
1
Embeds 0
No embeds

No notes for slide

Transcript of "RESTful Service Composition with JOpera"

  1. 1. RESTful Service Composition with JOpera Cesare Pautasso Faculty of Informatics, USI Lugano, Switzerland c.pautasso@ieee.org http://www.pautasso.info http://twitter.com/pautasso 21.5.2010
  2. 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 apply the notion of composition to RESTful services and discuss the conceptual relationship between business processes and stateful resources. Our goal is to enable 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 proceses as a resource and exposing in a controlled way the execution state of a service composition. To do so, we present how to build a composite application (DoodleMap) out of some well-known, public and currently existing RESTful service APIs. ©2009-2010 - Cesare Pautasso, Erik Wilde 2
  3. 3. From REST-* “ We believe there is huge potential to marrying REST with workflow and BPM. http://www.jboss.org/reststar/specifications/workflow.html […] 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. ©2010 - Cesare Pautasso 3
  4. 4. WS-BPEL Primitives Web <receive> <invoke> Service <reply> <invoke> Web <receive> Service  The workflow language natively supports the RPC or message-based connectors ©2010 - Cesare Pautasso 4
  5. 5. WS-BPEL Primitives Web <receive> <invoke> Service <reply>  Easy to map this to HTTP! Web <invoke> <receive> Service ©2010 - Cesare Pautasso 5
  6. 6. BPEL and WSDL 2.0 WSDL 2.0 HTTP Binding can wrap RESTful Web Services (WS-BPEL 2.0 does not support WSDL 2.0) ©2009-2010 - Cesare Pautasso, Erik Wilde 6
  7. 7. RESTful APIs… …do not use WSDL ©2010 - Cesare Pautasso 7
  8. 8. WS-BPEL Primitives Web <receive> <invoke> Service <reply>  Easy to map this to HTTP? Web <invoke> <receive> Service  We need something else ©2010 - Cesare Pautasso 8
  9. 9. From REST-* “ We believe there is huge potential to marrying REST with workflow and BPM. http://www.jboss.org/reststar/specifications/workflow.html  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. ©2010 - Cesare Pautasso 9
  10. 10. Outline 1. Introduction to RESTful Web Services 2. Defining RESTful Service Composition 3. JOpera Demo 4. More than Mashups? ©2009-2010 - Cesare Pautasso, Erik Wilde 10
  11. 11. REST in one slide  Web Services expose their data and functionality trough PUT resources identified by URI R  Uniform Interface Principle: GET Clients interact with resources POST through a fix set of verbs. DELETE 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 ©2010 - Cesare Pautasso 11
  12. 12. Design Methodology 1. Identify resources to be exposed as services (e.g., yearly risk report, book DELETE catalog, purchase order, open bugs, POST polls and votes) GET PUT 2. Model relationships (e.g., containment, reference, state transitions) between /loan     resources with hyperlinks that can be followed to get more details (or perform /balance     state transitions) /client     3. Define “nice” URIs to address the resources /book     4. Understand what it means to do a GET, POST, PUT, DELETE for each resource /order  ?   (and whether it is allowed or not) 5. Design and document resource representations /soap     6. Implement and deploy on Web server 7. Test with a Web browser ©2009-2010 - Cesare Pautasso, Erik Wilde 12
  13. 13. Design Space M Representations (Variable) ©2009-2010 - Cesare Pautasso, Erik Wilde 13
  14. 14. Simple Doodle API Example 1. Resources: DELETE polls and votes POST 2. Containment Relationship: GET PUT poll /poll     {id1} /poll/{id}     vote /poll/{id}/vote     {id4} /poll/{id}/vote/{id}    ? {id5} 3. URIs embed IDs of “child” instance resources 4. POST on the container is used to {id2} create child resources 5. PUT/DELETE for updating and {id3} removing child resources ©2009-2010 - Cesare Pautasso, Erik Wilde 14
  15. 15. Simple Doodle API Example 1. Creating a poll (transfer the state of a new poll on the Doodle service) /poll /poll/090331x /poll/090331x/vote POST /poll GET /poll/090331x <options>A,B,C</options> 200 OK 201 Created <options>A,B,C</options> Location: /poll/090331x <votes href=“/vote”/> 2. Reading a poll (transfer the state of the poll from the Doodle service) ©2009-2010 - Cesare Pautasso, Erik Wilde 15
  16. 16. Simple Doodle API Example  Participating in a poll by creating a new vote sub-resource /poll /poll/090331x /poll/090331x/vote /poll/090331x/vote/1 POST /poll/090331x/vote GET /poll/090331x <name>C. Pautasso</name> <choice>B</choice> 200 OK <options>A,B,C</options> 201 Created <votes><vote id=“1”> Location: <name>C. Pautasso</name> /poll/090331x/vote/1 <choice>B</choice> </vote></votes> ©2009-2010 - Cesare Pautasso, Erik Wilde 16
  17. 17. Simple Doodle API Example  Existing votes can be updated (access control headers not shown) /poll /poll/090331x /poll/090331x/vote /poll/090331x/vote/1 PUT /poll/090331x/vote/1 GET /poll/090331x <name>C. Pautasso</name> <choice>C</choice> 200 OK <options>A,B,C</options> 200 OK <votes><vote id=“/1”> <name>C. Pautasso</name> <choice>C</choice> </vote></votes> ©2009-2010 - Cesare Pautasso, Erik Wilde 17
  18. 18. Simple Doodle API Example  Polls can be deleted once a decision has been made /poll /poll/090331x /poll/090331x/vote /poll/090331x/vote/1 DELETE /poll/090331x GET /poll/090331x 200 OK 404 Not Found ©2009-2010 - Cesare Pautasso, Erik Wilde 18
  19. 19. Real Doodle Demo • Info on the real Doodle API: http://doodle.com/xsd1/RESTfulDoodle.pdf • Lightweight demo with Poster Firefox Extension: http://addons.mozilla.org/en-US/firefox/addon/2691 ©2009-2010 - Cesare Pautasso, Erik Wilde 19
  20. 20. Different software connectors RPC ESB WWW ©2010 - Cesare Pautasso 20
  21. 21. REST Architectural Elements Client/Server Layered Stateless Communication Cache Proxy User Agent Origin Server Gateway Connector (HTTP) Cache ©2009-2010 - Cesare Pautasso, Erik Wilde 21
  22. 22. Basic Setup HTTP User Agent Origin Server Adding Caching HTTP HTTP Caching Origin Server User Agent Caching User Agent Origin Server HTTP Caching Caching User Agent Origin Server ©2009-2010 - Cesare Pautasso, Erik Wilde 22
  23. 23. Proxy or Gateway? Intermediaries forward (and may translate) requests and responses HTTP HTTP Client Proxy Origin Server A proxy is chosen by the Client (for caching, or access control) HTTP HTTP Client Gateway Origin Server The use of a gateway (or reverse proxy) is imposed by the server ©2009-2010 - Cesare Pautasso, Erik Wilde 23
  24. 24. What about composition?  The basic REST design  WS-BPEL is the standard elements do not take Web service composition language. Business process composition into account models are used to specify how a collection of services HTTP is orchestrated into a composite service User Agent Origin Server  Can we apply WS-BPEL to RESTful services? HTTP Origin Server User Agent ? Origin Server ©2009-2010 - Cesare Pautasso, Erik Wilde 24
  25. 25. REST Scalability Cache Proxy/Gateway Origin Server Clients  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 ©2010 - Cesare Pautasso 25
  26. 26. REST Composition Proxy/Gateway Origin Server Clients  Composition shifts the attention to the client which should consume and aggregate from many servers ©2010 - Cesare Pautasso 26
  27. 27. REST Composition Client Composite Origin RESTful Servers service  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? ©2010 - Cesare Pautasso 27
  28. 28. Composite Resources DELETE PUT GET C DELETE DELETE POST PUT PUT GET R GET S POST POST ©2010 - Cesare Pautasso 28
  29. 29. Composite Resources  The composite resource only aggregates the state of its component resources C R S State R State S ©2010 - Cesare Pautasso 29
  30. 30. Composite Resources  The composite resource augments (or caches) the state of its component resources C State C R S State R State S ©2010 - Cesare Pautasso 30
  31. 31. Composite Representation DELETE PUT DELETE Composite GET R PUT Representation POST S C GET POST LinkR LinkS ©2010 - Cesare Pautasso 31
  32. 32. Composite Representation Composite Representation Origin Server Client Origin Servers  A composite representation is interpreted by the client that follows its hyperlinks and aggregates the state of the referenced component resources ©2010 - Cesare Pautasso 32
  33. 33. Bringing it all together Composite Representation Composite Origin RESTful Servers service Client Origin Servers  A composite representation can be produced by a composite service too ©2010 - Cesare Pautasso 33
  34. 34. Doodle Map Example Composite Representation Composite Origin RESTful Servers service Client Origin Servers  Vote on a meeting place based on its geographic location ©2010 - Cesare Pautasso 34
  35. 35. Composite Resource DELETE PUT GET C DELETE DELETE POST PUT PUT GET R GET S POST POST ©2010 - Cesare Pautasso 35
  36. 36. Composite Resource DELETE GET C DELETE POST PUT GET R GET S POST ©2010 - Cesare Pautasso 36
  37. 37. Composite Representation DM DELETE GET G LinkG GET C LinkC DELETE POST PUT LinkD GET R GET S POST ©2010 - Cesare Pautasso 37
  38. 38. Demo ©2009-2010 - Cesare Pautasso, Erik Wilde 38
  39. 39. Doodle Map Architecture Web Browser Workflow RESTful Engine Web Services RESTful API APIs GET POST GET ©2009-2010 - Cesare Pautasso, Erik Wilde 39
  40. 40. DoodleMap Model ©2010 - Cesare Pautasso 40
  41. 41. Viewpoints Control Data Flow Flow Service Bindings JAVA XPATH XSLT HTML HTTP … ©2010 - Cesare Pautasso 41
  42. 42. Control Flow Control Flow Dependency ©2010 - Cesare Pautasso 42
  43. 43. Service Bindings HTTP HTML XSLT XPATH JAVA … ©2010 - Cesare Pautasso 43
  44. 44. Data Flow Data Flow (Copy) ©2010 - Cesare Pautasso 44
  45. 45. Was it just a mashup? Mashup REST Composition (It depends on the definition of Mashup) ©2010 - Cesare Pautasso 45
  46. 46. Moving state around  Read-only vs. Read/Write DELETE PUT GET C DELETE DELETE POST PUT PUT GET R GET S POST POST ©2010 - Cesare Pautasso 46
  47. 47. Simply aggregating data  Read-only vs. Read/write GET C GET R GET S ©2010 - Cesare Pautasso 47
  48. 48. Is your composition reusable?  UI vs. API Composition Composite API Representation Composite Origin RESTful Servers UI service  Reusable Client Origin services vs. Servers Reusable Widgets ©2010 - Cesare Pautasso 48
  49. 49. Single-Origin Sandbox  Can you always do this from a web browser? Composite Representation Composite Origin RESTful Servers service Client Origin Servers ©2010 - Cesare Pautasso 49
  50. 50. Single-Origin Sandbox  Security Policies on the client may not always allow it to aggregate data from multiple different sources Composite Representation Composite N Origin RESTful Servers service Client 1 Origin Server  This will change very soon with HTML5 ©2010 - Cesare Pautasso 50
  51. 51. Complementary Read-Only Read/Write UI Mashup REST API Composition Reusable Situational Service Sandboxed ©2010 - Cesare Pautasso 51
  52. 52. Conclusions  REST brings a new perspective and new problems to service composition  RESTful services can be composed on the server by defining composite resources and on the client with composite representations  Composing RESTful services helps to put the integration logic of a mashup into a reusable service API and keep it separate from its UI made out of reusable widgets  RESTful Web service composition is different than mashups, but both can be built using BPM tools like JOpera  GET http://www.jopera.org/ ©2010 - Cesare Pautasso 52
  53. 53. References  Roy Fielding, Architectural Styles and the Design of Network-based Software Architectures, PhD Thesis, University of California, Irvine, 2000  Leonard Richardson, Sam Ruby, RESTful Web Services, O’Reilly, May 2007  Jim Webber, Savas Parastatidis, Ian Robinson, REST in Practice: Hypermedia and Systems Architecture, O‘Reilly, 2010  Subbu Allamaraju, RESTful Web Services Cookbook: Solutions for Improving Scalability and Simplicity, O’Reilly, 2010  Stevan Tilkov, HTTP und REST, dpunkt Verlag, 2009, http://rest-http.info/  Thomas Erl, Raj Balasubramanians, Cesare Pautasso, Benjamin Carlyle, SOA with REST, Prentice Hall, end of 2010  Martin Fowler, Richardson Maturity Model: steps toward the glory of REST, http://martinfowler.com/articles/richardsonMaturityModel.html ©2009-2010 - Cesare Pautasso, Erik Wilde 53
  54. 54. Self-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 and Erik Wilde. Why is the Web Loosely Coupled? A Multi- Faceted Metric for Service Design, Proc of the 18th International World Wide Web Conference (WWW2009), Madrid, Spain, April 2009.  Cesare Pautasso, BPEL for REST, Proc. of the 6th International Conference on Business Process Management (BPM 2008), Milan, Italy, September 2008.  Cesare Pautasso, RESTful Web Service Composition with JOpera, Proc. Of the International Conference on Software Composition (SC 2009), Zurich, Switzerland, July 2009.  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 2004. ©2009-2010 - Cesare Pautasso, Erik Wilde 54
  55. 55. Leonard Richardson, Raj Balasubramanians, Benjamin Sam Ruby, Carlyle,Thomas Erl, Cesare Pautasso, RESTful Web Services, SOA with REST, O’Reilly, May 2007 Prentice Hall, end of 2010 ©2009-2010 - Cesare Pautasso, Erik Wilde 55
  56. 56. Abstract Submission: Friday, July 16, 2010 ©2009-2010 - Cesare Pautasso, Erik Wilde 56

×