SlideShare a Scribd company logo
SOA with REST
          Cesare Pautasso
       Faculty of Informatics
  University of Lugano, Switzerland

        c.pautasso@ieee.org
     http://www.pautasso.info
©2010 - Cesare Pautasso   2
Abstract
            Recent technology trends in Web Services indicate that a
             solution eliminating the perceived complexity of the WS-*
             standard technology stack may be in sight: advocates of
             REpresentational State Transfer (REST) have come to
             believe that their ideas explaining why the World Wide Web
             works are just as applicable to solve enterprise application
             integration problems. In this talk we take a close look at the
             potential for convergence of service orientation and the
             REST architectural style. We highlight the benefits in terms
             of simplicity, loose coupling, and performance of a RESTful
             approach to SOA and discuss the most important SOA
             design patterns that become available once REST is
             introduced..


©2010 - Cesare Pautasso                                                       3
Acknowledgements
            The following distinguished individuals have
             contributed to the the patterns, ideas and reviewed
             some of the material presented in this talk:
                  Raj Balasubramanian
                  Benjamin Carlyle
                  Thomas Erl
                  Stefan Tilkov
                  Erik Wilde
                  Herbjorn Wilhelmsen
                  Jim Webber




©2010 - Cesare Pautasso                                            4
SOA with REST - Outline
   •         Introduction
   •         RESTful Service Design
   •         Simple Doodle Service Example & Demo
   •         Some REST-inspired SOA Design Patterns
          •        Entity Endpoint
          •        Uniform Contract
          •        Endpoint Redirection
          •        Content Negotiation
   • Discussion


©2010 - Cesare Pautasso                               5
Web Sites (1992)


               Web        HTML     Web
             Browser      HTTP     Server


WS-* Web Services (2000)

                          SOAP     WSDL
                 Client   XML      Server
                          (HTTP)
©2010 - Cesare Pautasso                     6
RESTful Web Services (2007)




                                 PO-XML
                                          RSS/Atom
                          JSON
                                                     WADL
                                                     Web
                 Client
                             HTTP                    Server

WS-* Web Services (2000)

                             SOAP                    WSDL
                 Client      XML                     Server
                            (HTTP)
©2010 - Cesare Pautasso                                       7
8




                      Slide from Paul Downey, BT
Is REST being used?
RESTful Service Design
   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
©2010 - Cesare Pautasso                                                                 9
Design Space
                          M Representations (Variable)




©2010 - Cesare Pautasso                                  10
A new kind of Service
   From Service Capabilities to Resources
   From Service Contracts to the Uniform Contract




             • GetInvoice              GET /invoices/{id}
             • ReportYearEnd           GET /reports/{year}
             • UpdateClient            PUT /clients/{id}



©2010 - Cesare Pautasso                                      11
Simple Doodle REST 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

©2010 - Cesare Pautasso                                                              12
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)
©2010 - Cesare Pautasso                                                              13
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>


©2010 - Cesare Pautasso                                           14
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>


©2010 - Cesare Pautasso                                                15
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




©2010 - Cesare Pautasso                                     16
What is your SOA Connector today?

                          RPC         ESB



                                WWW



©2010 - Cesare Pautasso                     17
Design Patterns
                          M Representations (Variable)
          Content
         Negotiation



      Entity                                         Uniform
     Endpoint                                        Contract



       Endpoint
       Redirect

©2010 - Cesare Pautasso                                         18
Pattern: Uniform Contract
                                        calculateRate()
                          Provider US
                                        retrieveTaxRate()
                          Provider CH
          Consumer
                                        figureOutRateForTax()
                          Provider IT

   How can consumers take advantage of multiple evolving
    service endpoints?
   Problem: Accessing similar services requires consumers to
    access capabilities expressed in service-specific contracts.
    The consumer needs to be kept up to date with respect to
    many evolving individual contracts.

©2010 - Cesare Pautasso                                            19
Pattern: Uniform Contract
                                        GET www.irs.gov/rate
                          Provider US
                                        GET www.admin.ch/tax/rate
                          Provider CH
          Consumer
                                        GET www.tesoro.it/tasse/iva
                          Provider IT

   Solution: Standardize a uniform contract across alternative
    service endpoints that is abstracted from the specific
    capabilities of individual services.
   Benefits: Service Abstraction, Loose Coupling, Reusability,
    Discoverability, Composability.

©2010 - Cesare Pautasso                                               20
Example Uniform Contract

             CRUD               HTTP
                                              Create a
           CREATE         POST              sub resource
                                       Retrieve the current
              READ        GET          state of the resource
                                       Initialize or update the
           UPDATE         PUT            state of a resource
                                           at the given URI

                                         Clear a resource,
           DELETE         DELETE         after the URI is no
                                            longer valid

©2010 - Cesare Pautasso                                           21
POST vs. GET
  GET is a read-only operation.
   It can be repeated without
   affecting the state of the
   resource (idempotent) and
   can be cached.
 Note: this does not mean that
   the same representation will
   be returned every time.         Web browsers warn
  POST is a read-write            you when refreshing
   operation and may change        a page generated
   the state of the resource and   with POST
   provoke side effects on the
   server.


©2010 - Cesare Pautasso                                  22
POST vs. PUT
  What is the right way of creating resources (initialize their state)?
         PUT /resource/{id}
         201 Created
            Problem: How to ensure resource {id} is unique?
            (Resources can be created by multiple clients concurrently)
            Solution 1: let the client choose a unique id (e.g., GUID)

         POST /resource
         301 Moved Permanently
         Location: /resource/{id}
            Solution 2: let the server compute the unique id
            Problem: Duplicate instances may be created if requests are
            repeated due to unreliable communication

©2010 - Cesare Pautasso                                                   23
Pattern: Endpoint Redirection
                                 Stale Reference

         Consumer                Service Endpoint
                          Redirect

          Consumer                   Old Endpoint   New Endpoint

   How can consumers of a service endpoint adapt when service
    inventories are restructured?
   Problem: Service inventories may change over time for
    business or technical reasons. It may not be possible to
    replace all references to old endpoints simultaneously.
   Solution: Automatically refer service consumers that access
    the stale endpoint identifier to the current identifier.
©2010 - Cesare Pautasso                                            24
Endpoint Redirection with HTTP
                                  /old   /new
                                HTTP natively supports
                                 the Endpoint redirection
         GET /old                pattern using a
                                 combination of 3xx
         301 Moved Permanently
         Location: /new
                                 status codes and
                                 standard headers:
                                                 301 Moved Permanently
                                                 307 Temporary Redirect
         GET /new
                                                 Location: /newURI
         200 OK

                           Tip: Redirection responses can be chained.
                           Warning: do not create redirection loops!
©2010 - Cesare Pautasso                                                    25
Pattern: Entity Endpoint
                                     Provider
                      Consumer       Endpoint
                                                        A   B   C
                                                        X   Y   Z
                                 X
                                                   Business Entities
                                 Z




   How can entities be positioned as reusable enterprise resources?
   Problem: A service with a single endpoint is too coarse-grained when its
    capabilities need to be invoked on its data entities. A consumer needs to
    work with two identifiers: a global one for the service and a local one for
    the entity managed by the service. Entity identifiers cannot be reused and
    shared among multiple services


©2010 - Cesare Pautasso                                                           26
Pattern: Entity Endpoint

                      Consumer      Provider Entity Endpoints
                                    X    Y     Z    A     B     C




   Solution: expose each entitity as individual lightweight
    endpoints of the service they reside in
   Benefits: Global addressability of service entities



©2010 - Cesare Pautasso                                             27
URI - Uniform Resource Identifier

    Internet Standard for resource naming and identification
     (originally from 1994, revised until 2005)
    Examples:
                    http://tools.ietf.org/html/rfc3986

                   URI Scheme   Authority     Path
                 https://www.google.ch/search?q=rest&start=10#1

                                                  Query      Fragment
    REST does not advocate the use of “nice” URIs
    In most HTTP stacks URIs cannot have arbitrary length (4Kb)


©2010 - Cesare Pautasso                                             28
What is a “nice” URI?
 A RESTful service is much more than just a set of nice URIs

   http://map.search.ch/lugano

                                         http://maps.google.com/lugano




                       http://maps.google.com/maps?f=q&hl=en&q=lugano,
                     +switzerland&layer=&ie=UTF8&z=12&om=1&iwloc=addr


©2010 - Cesare Pautasso                                                  29
URI Design Guidelines
   Prefer Nouns to Verbs      GET /book?isbn=24&action=delete
   Keep your URIs short       DELETE /book/24
   If possible follow a
    “positional” parameter-        Note: REST URIs are opaque
    passing scheme for              identifiers that are meant to
    algorithmic resource query      be discovered by following
    strings (instead of the         hyperlinks and not
    key=value&p=v encoding)         constructed by the client

   Some use URI postfixes to        This may break the
    specify the content type          abstraction

   Do not change URIs               Warning: URI Templates
   Use redirection if you really     introduce coupling between
    need to change them               client and server


©2010 - Cesare Pautasso                                             30
Pattern: Content Negotiation


                           Consumer
                                ?
                                         Service
                          New Consumer

   How can services support different consumers without
    changing their contract?
   Problem: Service consumers may change their requirements in
    a way that is not backwards compatible. A service may have to
    support both old and new consumers without having to
    introduce a specific capability for each kind of consumer.


©2010 - Cesare Pautasso                                             31
Pattern: Content Negotiation


                           Consumer

                                          Service
                          New Consumer

   Solution: specific content and data representation formats to
    be accepted or returned by a service capability is negotiated at
    runtime as part of its invocation. The service contract refers to
    multiple standardized “media types”.
   Benefits: Loose Coupling, Increased Interoperability, Increased
    Organizational Agility


©2010 - Cesare Pautasso                                                 32
Content Negotiation in HTTP
  Negotiating the message format does not require to send more
      messages (the added flexibility comes for free)
         GET /resource
         Accept: text/html, application/xml,
           application/json
            1. The client lists the set of understood formats (MIME types)

         200 OK
         Content-Type: application/json
            2. The server chooses the most appropriate one for the reply
            (status 406 if none can be found)




©2010 - Cesare Pautasso                                                      33
Advanced Content Negotiation
  Quality factors allow the client to indicate the relative
     degree of preference for each representation (or
     media-range).
                            Media/Type; q=X
  If a media type has a quality value q=0, then content with
       this parameter is not acceptable for the client.
             Accept: text/html, text/*; q=0.1
            The client prefers to receive HTML (but any other text format
            will do with lower priority)
    Accept: application/xhtml+xml; q=0.9,
      text/html; q=0.5, text/plain; q=0.1
            The client prefers to receive XHTML, or HTML if this is not
            available and will use Plain Text as a fall back


©2010 - Cesare Pautasso                                                     34
Forced Content Negotiation
  The generic URI supports content negotiation
  GET /resource
  Accept: text/html, application/xml,
     application/json
  The specific URI points to a specific representation format using
      the postfix (extension)
  GET /resource.html
  GET /resource.xml
  GET /resource.json
  Warning: This is a conventional practice, not a standard.
  What happens if the resource cannot be represented in the
      requested format?

©2010 - Cesare Pautasso                                               35
Multi-Dimensional Negotiation
  Content Negotiation is very flexible and can be
     performed based on different dimensions
     (each with a specific pair of HTTP headers).

    Request Header Example Values Response Header
    Accept:          application/xml, Content-Type:
                     application/json
    Accept-Language: en, fr, de, es   Content-Language:

    Accept-Charset:  iso-8859-5,      Charset parameter fo the
                     unicode-1-1      Content-Type header
    Accept-Encoding: compress,        Content-Encoding:
                     gzip




©2010 - Cesare Pautasso                                          36
More SOA with REST Patterns
   1. Uniform Contract
   2. Entity Endpoint
   3. Entity Linking*
   4. Content Negotiation
   5. Distributed Response Caching*
   6. Endpoint Redirection
   7. Idempotent Capability*
   8. Message-based State Deferral*
   9. Message-based Logic Deferral*
   10.Consumer-Processed Composition*
                            *Not Included in this talk
©2010 - Cesare Pautasso                                  37
Conclusion




             • GetInvoice      GET /invoices/{id}
             • ReportYearEnd   GET /reports/{year}
             • UpdateClient    PUT /clients/{id}



©2010 - Cesare Pautasso                              38
Conclusion
      SOA comes from the business IT domain, while REST
       comes from the World Wide Web.
      REST is more at home with HTTP and HTML, while SOA is
       more at home with SOAP and WSDL.
      Some REST advocates see the Web Services stack both
       as begin synonymous with SOA and as an invader in the
       architecture of the "real" Web. Some SOA advocates see
       REST as an unnecessary diversion from ensuring
       connectivity between enterprise service bus technologies
       supplied by different vendors.
      Despite their different histories, REST and SOA can learn
       a lot from each other.
      SOA with REST aims to forge an effective architectural
       model both for enterprise computing and for computing
       on the World Wide Web that brings the best of both
       worlds together

©2010 - Cesare Pautasso                                            39
References
     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.
     R. Balasubramanian, B. Carlyle, T. Erl, C. Pautasso, SOA with REST,
      Prentice Hall (to appear in 2010)
     Doodle RESTful API, http://doodle.com/xsd1/RESTfulDoodle.pdf
©                                                                               40

More Related Content

Similar to SOA2010 SOA with REST

RESTful Service Composition with JOpera
RESTful Service Composition with JOperaRESTful Service Composition with JOpera
RESTful Service Composition with JOpera
Cesare Pautasso
 
BPM with REST
BPM with RESTBPM with REST
BPM with REST
Cesare Pautasso
 
Paul Fremantle Restful SOA Registry
Paul Fremantle Restful SOA RegistryPaul Fremantle Restful SOA Registry
Paul Fremantle Restful SOA Registrydeimos
 
REST vs. SOAP
REST vs. SOAPREST vs. SOAP
REST vs. SOAP
Murat Çakal
 
Modified REST Presentation
Modified REST PresentationModified REST Presentation
Modified REST Presentation
Alexandros Marinos
 
Mapping the RESTful Programming Model to the DDS Data-Centric Model
Mapping the RESTful Programming Model to the DDS Data-Centric ModelMapping the RESTful Programming Model to the DDS Data-Centric Model
Mapping the RESTful Programming Model to the DDS Data-Centric Model
Rick Warren
 
Techniques for Composing REST services - SOA Symposium 2009
Techniques for Composing REST services - SOA Symposium 2009Techniques for Composing REST services - SOA Symposium 2009
Techniques for Composing REST services - SOA Symposium 2009Cesare Pautasso
 
REST: Theory vs Practice
REST: Theory vs PracticeREST: Theory vs Practice
REST: Theory vs Practice
Subbu Allamaraju
 
Pinterest like site using REST and Bottle
Pinterest like site using REST and Bottle Pinterest like site using REST and Bottle
Pinterest like site using REST and Bottle Gaurav Bhardwaj
 
Cesare Pautasso R E S T V1
Cesare  Pautasso    R E S T V1Cesare  Pautasso    R E S T V1
Cesare Pautasso R E S T V1SOA Symposium
 
REST Servers in Delphi XE Using DataSnap
REST Servers in Delphi XE Using DataSnapREST Servers in Delphi XE Using DataSnap
REST Servers in Delphi XE Using DataSnap
Embarcadero Technologies
 
How to build a rest api
How to build a rest apiHow to build a rest api
How to build a rest api
Hoang Nguyen
 
REST vs WS-*: Myths Facts and Lies
REST vs WS-*: Myths Facts and LiesREST vs WS-*: Myths Facts and Lies
REST vs WS-*: Myths Facts and Lies
Paul Fremantle
 
WCF Data Services - Bandung Charity Event - 2010
WCF Data Services  - Bandung Charity Event - 2010WCF Data Services  - Bandung Charity Event - 2010
WCF Data Services - Bandung Charity Event - 2010Andri Yadi
 
Introduction To REST
Introduction To RESTIntroduction To REST
Introduction To REST
rainynovember12
 
RESTFul WebApp Concept
RESTFul WebApp ConceptRESTFul WebApp Concept
RESTFul WebApp ConceptDian Aditya
 
RESTFul WebApp Concept
RESTFul WebApp ConceptRESTFul WebApp Concept
RESTFul WebApp ConceptDian Aditya
 
Differentiating between web APIs, SOA, & integration …and why it matters
Differentiating between web APIs, SOA, & integration…and why it mattersDifferentiating between web APIs, SOA, & integration…and why it matters
Differentiating between web APIs, SOA, & integration …and why it matters
Kim Clark
 
Navigating the Programmable Web
Navigating the Programmable WebNavigating the Programmable Web
Navigating the Programmable Web
goodfriday
 

Similar to SOA2010 SOA with REST (20)

RESTful Service Composition with JOpera
RESTful Service Composition with JOperaRESTful Service Composition with JOpera
RESTful Service Composition with JOpera
 
BPM with REST
BPM with RESTBPM with REST
BPM with REST
 
Paul Fremantle Restful SOA Registry
Paul Fremantle Restful SOA RegistryPaul Fremantle Restful SOA Registry
Paul Fremantle Restful SOA Registry
 
REST vs. SOAP
REST vs. SOAPREST vs. SOAP
REST vs. SOAP
 
Modified REST Presentation
Modified REST PresentationModified REST Presentation
Modified REST Presentation
 
Mapping the RESTful Programming Model to the DDS Data-Centric Model
Mapping the RESTful Programming Model to the DDS Data-Centric ModelMapping the RESTful Programming Model to the DDS Data-Centric Model
Mapping the RESTful Programming Model to the DDS Data-Centric Model
 
Techniques for Composing REST services - SOA Symposium 2009
Techniques for Composing REST services - SOA Symposium 2009Techniques for Composing REST services - SOA Symposium 2009
Techniques for Composing REST services - SOA Symposium 2009
 
REST: Theory vs Practice
REST: Theory vs PracticeREST: Theory vs Practice
REST: Theory vs Practice
 
Pinterest like site using REST and Bottle
Pinterest like site using REST and Bottle Pinterest like site using REST and Bottle
Pinterest like site using REST and Bottle
 
Cesare Pautasso R E S T V1
Cesare  Pautasso    R E S T V1Cesare  Pautasso    R E S T V1
Cesare Pautasso R E S T V1
 
Soa limitations
Soa limitationsSoa limitations
Soa limitations
 
REST Servers in Delphi XE Using DataSnap
REST Servers in Delphi XE Using DataSnapREST Servers in Delphi XE Using DataSnap
REST Servers in Delphi XE Using DataSnap
 
How to build a rest api
How to build a rest apiHow to build a rest api
How to build a rest api
 
REST vs WS-*: Myths Facts and Lies
REST vs WS-*: Myths Facts and LiesREST vs WS-*: Myths Facts and Lies
REST vs WS-*: Myths Facts and Lies
 
WCF Data Services - Bandung Charity Event - 2010
WCF Data Services  - Bandung Charity Event - 2010WCF Data Services  - Bandung Charity Event - 2010
WCF Data Services - Bandung Charity Event - 2010
 
Introduction To REST
Introduction To RESTIntroduction To REST
Introduction To REST
 
RESTFul WebApp Concept
RESTFul WebApp ConceptRESTFul WebApp Concept
RESTFul WebApp Concept
 
RESTFul WebApp Concept
RESTFul WebApp ConceptRESTFul WebApp Concept
RESTFul WebApp Concept
 
Differentiating between web APIs, SOA, & integration …and why it matters
Differentiating between web APIs, SOA, & integration…and why it mattersDifferentiating between web APIs, SOA, & integration…and why it matters
Differentiating between web APIs, SOA, & integration …and why it matters
 
Navigating the Programmable Web
Navigating the Programmable WebNavigating the Programmable Web
Navigating the Programmable Web
 

More from Cesare Pautasso

Beautiful APIs - SOSE2021 Keynote
Beautiful APIs - SOSE2021 KeynoteBeautiful APIs - SOSE2021 Keynote
Beautiful APIs - SOSE2021 Keynote
Cesare Pautasso
 
How do you back up and consistently recover your microservice architecture?
How do you back up and consistently recover your microservice architecture?How do you back up and consistently recover your microservice architecture?
How do you back up and consistently recover your microservice architecture?
Cesare Pautasso
 
Microservices: An Eventually Inconsistent Architectural Style?
Microservices: An Eventually Inconsistent Architectural Style?Microservices: An Eventually Inconsistent Architectural Style?
Microservices: An Eventually Inconsistent Architectural Style?
Cesare Pautasso
 
Disaster Recovery and Microservices: The BAC Theorem
Disaster Recovery and Microservices: The BAC TheoremDisaster Recovery and Microservices: The BAC Theorem
Disaster Recovery and Microservices: The BAC Theorem
Cesare Pautasso
 
The Blockchain as a Software Connector
The Blockchain as a Software ConnectorThe Blockchain as a Software Connector
The Blockchain as a Software Connector
Cesare Pautasso
 
Team Situational Awareness and Architectural Decision Making with the Softwar...
Team Situational Awareness and Architectural Decision Making with the Softwar...Team Situational Awareness and Architectural Decision Making with the Softwar...
Team Situational Awareness and Architectural Decision Making with the Softwar...
Cesare Pautasso
 
JOpera - Eclipse-based Visual Composition Environment featuring a general lan...
JOpera - Eclipse-based Visual Composition Environment featuring a general lan...JOpera - Eclipse-based Visual Composition Environment featuring a general lan...
JOpera - Eclipse-based Visual Composition Environment featuring a general lan...
Cesare Pautasso
 
Push-Enabling RESTful Business Processes
Push-Enabling RESTful Business ProcessesPush-Enabling RESTful Business Processes
Push-Enabling RESTful Business Processes
Cesare Pautasso
 
BPMN for REST
BPMN for RESTBPMN for REST
BPMN for REST
Cesare Pautasso
 
Service Oriented Architectures and Web Services
Service Oriented Architectures and Web ServicesService Oriented Architectures and Web Services
Service Oriented Architectures and Web Services
Cesare Pautasso
 
Exploiting Multicores to Optimize Business Process Execution
Exploiting Multicores to Optimize Business Process ExecutionExploiting Multicores to Optimize Business Process Execution
Exploiting Multicores to Optimize Business Process Execution
Cesare Pautasso
 
Real-time Mashups di Web Service Geografici
Real-time Mashups di Web Service GeograficiReal-time Mashups di Web Service Geografici
Real-time Mashups di Web Service Geografici
Cesare Pautasso
 
Towards Scalable Service Composition on Multicores
Towards Scalable Service Composition on MulticoresTowards Scalable Service Composition on Multicores
Towards Scalable Service Composition on Multicores
Cesare Pautasso
 
USI SCUBE Associate Member
USI SCUBE Associate MemberUSI SCUBE Associate Member
USI SCUBE Associate Member
Cesare Pautasso
 
Lighweight Collaboration Management (Mashups09@OOPSLA)
Lighweight Collaboration Management (Mashups09@OOPSLA)Lighweight Collaboration Management (Mashups09@OOPSLA)
Lighweight Collaboration Management (Mashups09@OOPSLA)
Cesare Pautasso
 
Composing RESTful Services with JOpera
Composing RESTful Services with JOperaComposing RESTful Services with JOpera
Composing RESTful Services with JOpera
Cesare Pautasso
 
Scientific and Grid Workflow Management (SGS09)
Scientific and Grid Workflow Management (SGS09)Scientific and Grid Workflow Management (SGS09)
Scientific and Grid Workflow Management (SGS09)Cesare Pautasso
 
Composing REST Services
Composing REST ServicesComposing REST Services
Composing REST Services
Cesare Pautasso
 
Mashup Ecosystem
Mashup EcosystemMashup Ecosystem
Mashup Ecosystem
Cesare Pautasso
 

More from Cesare Pautasso (20)

Beautiful APIs - SOSE2021 Keynote
Beautiful APIs - SOSE2021 KeynoteBeautiful APIs - SOSE2021 Keynote
Beautiful APIs - SOSE2021 Keynote
 
How do you back up and consistently recover your microservice architecture?
How do you back up and consistently recover your microservice architecture?How do you back up and consistently recover your microservice architecture?
How do you back up and consistently recover your microservice architecture?
 
Microservices: An Eventually Inconsistent Architectural Style?
Microservices: An Eventually Inconsistent Architectural Style?Microservices: An Eventually Inconsistent Architectural Style?
Microservices: An Eventually Inconsistent Architectural Style?
 
Disaster Recovery and Microservices: The BAC Theorem
Disaster Recovery and Microservices: The BAC TheoremDisaster Recovery and Microservices: The BAC Theorem
Disaster Recovery and Microservices: The BAC Theorem
 
The Blockchain as a Software Connector
The Blockchain as a Software ConnectorThe Blockchain as a Software Connector
The Blockchain as a Software Connector
 
Team Situational Awareness and Architectural Decision Making with the Softwar...
Team Situational Awareness and Architectural Decision Making with the Softwar...Team Situational Awareness and Architectural Decision Making with the Softwar...
Team Situational Awareness and Architectural Decision Making with the Softwar...
 
JOpera - Eclipse-based Visual Composition Environment featuring a general lan...
JOpera - Eclipse-based Visual Composition Environment featuring a general lan...JOpera - Eclipse-based Visual Composition Environment featuring a general lan...
JOpera - Eclipse-based Visual Composition Environment featuring a general lan...
 
Push-Enabling RESTful Business Processes
Push-Enabling RESTful Business ProcessesPush-Enabling RESTful Business Processes
Push-Enabling RESTful Business Processes
 
BPMN for REST
BPMN for RESTBPMN for REST
BPMN for REST
 
Service Oriented Architectures and Web Services
Service Oriented Architectures and Web ServicesService Oriented Architectures and Web Services
Service Oriented Architectures and Web Services
 
Exploiting Multicores to Optimize Business Process Execution
Exploiting Multicores to Optimize Business Process ExecutionExploiting Multicores to Optimize Business Process Execution
Exploiting Multicores to Optimize Business Process Execution
 
Real-time Mashups di Web Service Geografici
Real-time Mashups di Web Service GeograficiReal-time Mashups di Web Service Geografici
Real-time Mashups di Web Service Geografici
 
Towards Scalable Service Composition on Multicores
Towards Scalable Service Composition on MulticoresTowards Scalable Service Composition on Multicores
Towards Scalable Service Composition on Multicores
 
USI SCUBE Associate Member
USI SCUBE Associate MemberUSI SCUBE Associate Member
USI SCUBE Associate Member
 
Lighweight Collaboration Management (Mashups09@OOPSLA)
Lighweight Collaboration Management (Mashups09@OOPSLA)Lighweight Collaboration Management (Mashups09@OOPSLA)
Lighweight Collaboration Management (Mashups09@OOPSLA)
 
Mashups09
Mashups09Mashups09
Mashups09
 
Composing RESTful Services with JOpera
Composing RESTful Services with JOperaComposing RESTful Services with JOpera
Composing RESTful Services with JOpera
 
Scientific and Grid Workflow Management (SGS09)
Scientific and Grid Workflow Management (SGS09)Scientific and Grid Workflow Management (SGS09)
Scientific and Grid Workflow Management (SGS09)
 
Composing REST Services
Composing REST ServicesComposing REST Services
Composing REST Services
 
Mashup Ecosystem
Mashup EcosystemMashup Ecosystem
Mashup Ecosystem
 

Recently uploaded

The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 

Recently uploaded (20)

The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 

SOA2010 SOA with REST

  • 1. SOA with REST Cesare Pautasso Faculty of Informatics University of Lugano, Switzerland c.pautasso@ieee.org http://www.pautasso.info
  • 2. ©2010 - Cesare Pautasso 2
  • 3. Abstract  Recent technology trends in Web Services indicate that a solution eliminating the perceived complexity of the WS-* standard technology stack may be in sight: advocates of REpresentational State Transfer (REST) have come to believe that their ideas explaining why the World Wide Web works are just as applicable to solve enterprise application integration problems. In this talk we take a close look at the potential for convergence of service orientation and the REST architectural style. We highlight the benefits in terms of simplicity, loose coupling, and performance of a RESTful approach to SOA and discuss the most important SOA design patterns that become available once REST is introduced.. ©2010 - Cesare Pautasso 3
  • 4. Acknowledgements  The following distinguished individuals have contributed to the the patterns, ideas and reviewed some of the material presented in this talk:  Raj Balasubramanian  Benjamin Carlyle  Thomas Erl  Stefan Tilkov  Erik Wilde  Herbjorn Wilhelmsen  Jim Webber ©2010 - Cesare Pautasso 4
  • 5. SOA with REST - Outline • Introduction • RESTful Service Design • Simple Doodle Service Example & Demo • Some REST-inspired SOA Design Patterns • Entity Endpoint • Uniform Contract • Endpoint Redirection • Content Negotiation • Discussion ©2010 - Cesare Pautasso 5
  • 6. Web Sites (1992) Web HTML Web Browser HTTP Server WS-* Web Services (2000) SOAP WSDL Client XML Server (HTTP) ©2010 - Cesare Pautasso 6
  • 7. RESTful Web Services (2007) PO-XML RSS/Atom JSON WADL Web Client HTTP Server WS-* Web Services (2000) SOAP WSDL Client XML Server (HTTP) ©2010 - Cesare Pautasso 7
  • 8. 8 Slide from Paul Downey, BT Is REST being used?
  • 9. RESTful Service Design 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 ©2010 - Cesare Pautasso 9
  • 10. Design Space M Representations (Variable) ©2010 - Cesare Pautasso 10
  • 11. A new kind of Service  From Service Capabilities to Resources  From Service Contracts to the Uniform Contract • GetInvoice GET /invoices/{id} • ReportYearEnd GET /reports/{year} • UpdateClient PUT /clients/{id} ©2010 - Cesare Pautasso 11
  • 12. Simple Doodle REST 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 ©2010 - Cesare Pautasso 12
  • 13. 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) ©2010 - Cesare Pautasso 13
  • 14. 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> ©2010 - Cesare Pautasso 14
  • 15. 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> ©2010 - Cesare Pautasso 15
  • 16. 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 ©2010 - Cesare Pautasso 16
  • 17. What is your SOA Connector today? RPC ESB WWW ©2010 - Cesare Pautasso 17
  • 18. Design Patterns M Representations (Variable) Content Negotiation Entity Uniform Endpoint Contract Endpoint Redirect ©2010 - Cesare Pautasso 18
  • 19. Pattern: Uniform Contract calculateRate() Provider US retrieveTaxRate() Provider CH Consumer figureOutRateForTax() Provider IT  How can consumers take advantage of multiple evolving service endpoints?  Problem: Accessing similar services requires consumers to access capabilities expressed in service-specific contracts. The consumer needs to be kept up to date with respect to many evolving individual contracts. ©2010 - Cesare Pautasso 19
  • 20. Pattern: Uniform Contract GET www.irs.gov/rate Provider US GET www.admin.ch/tax/rate Provider CH Consumer GET www.tesoro.it/tasse/iva Provider IT  Solution: Standardize a uniform contract across alternative service endpoints that is abstracted from the specific capabilities of individual services.  Benefits: Service Abstraction, Loose Coupling, Reusability, Discoverability, Composability. ©2010 - Cesare Pautasso 20
  • 21. Example Uniform Contract CRUD HTTP Create a CREATE POST sub resource Retrieve the current READ GET state of the resource Initialize or update the UPDATE PUT state of a resource at the given URI Clear a resource, DELETE DELETE after the URI is no longer valid ©2010 - Cesare Pautasso 21
  • 22. POST vs. GET  GET is a read-only operation. It can be repeated without affecting the state of the resource (idempotent) and can be cached. Note: this does not mean that the same representation will be returned every time. Web browsers warn  POST is a read-write you when refreshing operation and may change a page generated the state of the resource and with POST provoke side effects on the server. ©2010 - Cesare Pautasso 22
  • 23. POST vs. PUT What is the right way of creating resources (initialize their state)? PUT /resource/{id} 201 Created Problem: How to ensure resource {id} is unique? (Resources can be created by multiple clients concurrently) Solution 1: let the client choose a unique id (e.g., GUID) POST /resource 301 Moved Permanently Location: /resource/{id} Solution 2: let the server compute the unique id Problem: Duplicate instances may be created if requests are repeated due to unreliable communication ©2010 - Cesare Pautasso 23
  • 24. Pattern: Endpoint Redirection Stale Reference Consumer Service Endpoint Redirect Consumer Old Endpoint New Endpoint  How can consumers of a service endpoint adapt when service inventories are restructured?  Problem: Service inventories may change over time for business or technical reasons. It may not be possible to replace all references to old endpoints simultaneously.  Solution: Automatically refer service consumers that access the stale endpoint identifier to the current identifier. ©2010 - Cesare Pautasso 24
  • 25. Endpoint Redirection with HTTP /old /new  HTTP natively supports the Endpoint redirection GET /old pattern using a combination of 3xx 301 Moved Permanently Location: /new status codes and standard headers:  301 Moved Permanently  307 Temporary Redirect GET /new  Location: /newURI 200 OK  Tip: Redirection responses can be chained.  Warning: do not create redirection loops! ©2010 - Cesare Pautasso 25
  • 26. Pattern: Entity Endpoint Provider Consumer Endpoint A B C X Y Z X Business Entities Z  How can entities be positioned as reusable enterprise resources?  Problem: A service with a single endpoint is too coarse-grained when its capabilities need to be invoked on its data entities. A consumer needs to work with two identifiers: a global one for the service and a local one for the entity managed by the service. Entity identifiers cannot be reused and shared among multiple services ©2010 - Cesare Pautasso 26
  • 27. Pattern: Entity Endpoint Consumer Provider Entity Endpoints X Y Z A B C  Solution: expose each entitity as individual lightweight endpoints of the service they reside in  Benefits: Global addressability of service entities ©2010 - Cesare Pautasso 27
  • 28. URI - Uniform Resource Identifier  Internet Standard for resource naming and identification (originally from 1994, revised until 2005)  Examples: http://tools.ietf.org/html/rfc3986 URI Scheme Authority Path https://www.google.ch/search?q=rest&start=10#1 Query Fragment  REST does not advocate the use of “nice” URIs  In most HTTP stacks URIs cannot have arbitrary length (4Kb) ©2010 - Cesare Pautasso 28
  • 29. What is a “nice” URI? A RESTful service is much more than just a set of nice URIs http://map.search.ch/lugano http://maps.google.com/lugano http://maps.google.com/maps?f=q&hl=en&q=lugano, +switzerland&layer=&ie=UTF8&z=12&om=1&iwloc=addr ©2010 - Cesare Pautasso 29
  • 30. URI Design Guidelines  Prefer Nouns to Verbs GET /book?isbn=24&action=delete  Keep your URIs short DELETE /book/24  If possible follow a “positional” parameter-  Note: REST URIs are opaque passing scheme for identifiers that are meant to algorithmic resource query be discovered by following strings (instead of the hyperlinks and not key=value&p=v encoding) constructed by the client  Some use URI postfixes to  This may break the specify the content type abstraction  Do not change URIs  Warning: URI Templates  Use redirection if you really introduce coupling between need to change them client and server ©2010 - Cesare Pautasso 30
  • 31. Pattern: Content Negotiation Consumer ? Service New Consumer  How can services support different consumers without changing their contract?  Problem: Service consumers may change their requirements in a way that is not backwards compatible. A service may have to support both old and new consumers without having to introduce a specific capability for each kind of consumer. ©2010 - Cesare Pautasso 31
  • 32. Pattern: Content Negotiation Consumer Service New Consumer  Solution: specific content and data representation formats to be accepted or returned by a service capability is negotiated at runtime as part of its invocation. The service contract refers to multiple standardized “media types”.  Benefits: Loose Coupling, Increased Interoperability, Increased Organizational Agility ©2010 - Cesare Pautasso 32
  • 33. Content Negotiation in HTTP Negotiating the message format does not require to send more messages (the added flexibility comes for free) GET /resource Accept: text/html, application/xml, application/json 1. The client lists the set of understood formats (MIME types) 200 OK Content-Type: application/json 2. The server chooses the most appropriate one for the reply (status 406 if none can be found) ©2010 - Cesare Pautasso 33
  • 34. Advanced Content Negotiation Quality factors allow the client to indicate the relative degree of preference for each representation (or media-range). Media/Type; q=X If a media type has a quality value q=0, then content with this parameter is not acceptable for the client. Accept: text/html, text/*; q=0.1 The client prefers to receive HTML (but any other text format will do with lower priority) Accept: application/xhtml+xml; q=0.9, text/html; q=0.5, text/plain; q=0.1 The client prefers to receive XHTML, or HTML if this is not available and will use Plain Text as a fall back ©2010 - Cesare Pautasso 34
  • 35. Forced Content Negotiation The generic URI supports content negotiation GET /resource Accept: text/html, application/xml, application/json The specific URI points to a specific representation format using the postfix (extension) GET /resource.html GET /resource.xml GET /resource.json Warning: This is a conventional practice, not a standard. What happens if the resource cannot be represented in the requested format? ©2010 - Cesare Pautasso 35
  • 36. Multi-Dimensional Negotiation Content Negotiation is very flexible and can be performed based on different dimensions (each with a specific pair of HTTP headers). Request Header Example Values Response Header Accept: application/xml, Content-Type: application/json Accept-Language: en, fr, de, es Content-Language: Accept-Charset: iso-8859-5, Charset parameter fo the unicode-1-1 Content-Type header Accept-Encoding: compress, Content-Encoding: gzip ©2010 - Cesare Pautasso 36
  • 37. More SOA with REST Patterns 1. Uniform Contract 2. Entity Endpoint 3. Entity Linking* 4. Content Negotiation 5. Distributed Response Caching* 6. Endpoint Redirection 7. Idempotent Capability* 8. Message-based State Deferral* 9. Message-based Logic Deferral* 10.Consumer-Processed Composition* *Not Included in this talk ©2010 - Cesare Pautasso 37
  • 38. Conclusion • GetInvoice GET /invoices/{id} • ReportYearEnd GET /reports/{year} • UpdateClient PUT /clients/{id} ©2010 - Cesare Pautasso 38
  • 39. Conclusion  SOA comes from the business IT domain, while REST comes from the World Wide Web.  REST is more at home with HTTP and HTML, while SOA is more at home with SOAP and WSDL.  Some REST advocates see the Web Services stack both as begin synonymous with SOA and as an invader in the architecture of the "real" Web. Some SOA advocates see REST as an unnecessary diversion from ensuring connectivity between enterprise service bus technologies supplied by different vendors.  Despite their different histories, REST and SOA can learn a lot from each other.  SOA with REST aims to forge an effective architectural model both for enterprise computing and for computing on the World Wide Web that brings the best of both worlds together ©2010 - Cesare Pautasso 39
  • 40. References  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.  R. Balasubramanian, B. Carlyle, T. Erl, C. Pautasso, SOA with REST, Prentice Hall (to appear in 2010)  Doodle RESTful API, http://doodle.com/xsd1/RESTfulDoodle.pdf © 40