SlideShare a Scribd company logo
Teaching Old Services New
Tricks: Adding HATEOAS Support
        as an Afterthought
   Olga Liskin, Leif Singer, Kurt Schneider
   {olga.liskin, leif.singer, kurt.schneider}
            @inf.uni-hannover.de
                    28.03.2011
Content
    Motivation
    Main Goals
    Service Example
    Terminology
    Notation for Application Models
    Conception of Wrapper Component
    Comparison
    Conclusions & Outlook




            Teaching Old Services New Tricks – Olga Liskin, Leif Singer, Kurt Schneider   28.03.2011   2
Motivation
  Problem with web service communication: Client needs to
  know exactly, what a request has to look like
  Many sources for errors
  –  Coding errors
  –  Invalid requests
  Idea: Server includes request-information in response
  messages
  –  Which requests allowed next
  –  What they look like
  HATEOAS
  But: not many services conform to this principle



            Teaching Old Services New Tricks – Olga Liskin, Leif Singer, Kurt Schneider   28.03.2011   3
Motivation
Example:


     Service response without HATEOAS:

     HTTP/1.1 200 OK
                                            What can the client
     Last-Modified: Wed, 01 Dec 2010 17:36:02 GMT next?
                                                 do
     Content-Type: application/xml
     <task>
       <id>208</id>
       <name>create GUI</name>              No idea. The client
       <status>inprogress</status>            has to know by
                                                   itself.
       <parentStoryId>04</parentStoryId>
     </task>




             Teaching Old Services New Tricks – Olga Liskin, Leif Singer, Kurt Schneider   28.03.2011   4
Motivation
Example:
     Service response with HATEOAS:

     HTTP/1.1 200 OK
     Last-Modified: Wed, 01 Dec 2010 17:36:02 GMT                                Control elements
     Content-Type: application/xml                                               directly present in
     Link: <stories/04/tasks/208/finish>; rel=“finish”                          response message.
     Link: <stories/04/tasks/208/block>; rel=“block”
     <task>
       <id>208</id>                                                             Now client can see
       <name>create GUI</name>                                                  following requests
       <status>inprogress</status>                                               and how to make
                                                                                       them
       <parentStory>/stories/04</parentStory>
     </task>



        …and also indicate
              this




            Teaching Old Services New Tricks – Olga Liskin, Leif Singer, Kurt Schneider                28.03.2011   5
Main Goals
  Create HATEOAS support using state charts
  –  Automatically generate a wrapper

                           Service
                         Information
                                       Generator/
                                                              Wrapper
                                       Interpreter
             Developer




                                          Client              Wrapper              Server




  Prerequisite: Clear way to model network-based applications
  –  State Charts
  –  Terminology


           Teaching Old Services New Tricks – Olga Liskin, Leif Singer, Kurt Schneider      28.03.2011   6
Service Example
Backlog service: support agile development projects
   Backlog
   –  contains story cards


  Story Card
   –  One particular topic
   –  Different states
         „definde“, „in progress“, „blocked“,…
         Depend on included tasks

  Task
   –  Story Card divided into tasks
   –  Different states
         Changed by user




             Teaching Old Services New Tricks – Olga Liskin, Leif Singer, Kurt Schneider   28.03.2011   7
1 Modelling Network-Based
Applications

   Teaching Old Services New Tricks – Olga Liskin, Leif Singer, Kurt Schneider   28.03.2011   8
Terminology
  Valid requests depend on current application state
  What exactly is application state?

  Relevant terminology:
  –  application
         „representation of the business-aware functionality of a system“ (Fielding)
  –  resource state
         Values of a resource‘s attributes
  –  application state
         Requests, responses and the processing of those
         E.g.: „process detail view of a story card“




             Teaching Old Services New Tricks – Olga Liskin, Leif Singer, Kurt Schneider   28.03.2011   9
Terminology

                                                                   31

                                                                                             finished



Backlog                                                08
                                                                                        24




                                                                                 blocked
  New idea:                                                                                     Story
   –  Equivalence classes of application states
            Combine „similar“ states
            Determined by resource class and resource state




               Teaching Old Services New Tricks – Olga Liskin, Leif Singer, Kurt Schneider     28.03.2011   10
State Chart
  States
  –  Equivalence classes of application states
  –  Composite States combine states with same resource class




           Teaching Old Services New Tricks – Olga Liskin, Leif Singer, Kurt Schneider   28.03.2011   11
State Chart
  Transitions
  –  Possible change of application state
        triggered by new client request
  –  Target state reached in case of success
  Transitions between Simple States




            Teaching Old Services New Tricks – Olga Liskin, Leif Singer, Kurt Schneider   28.03.2011   12
State Chart
  Transitions between Composite States
  –  More precise information about control flow
      necessary
  –  Outgoing transition:
        Transition possible from all sub-states


  –  Incoming transition:
        Client requests a resource of
        particular class
        Sub-state can only be determined
        at runtime
        choice-pseudostate




            Teaching Old Services New Tricks – Olga Liskin, Leif Singer, Kurt Schneider   28.03.2011   13
State Chart
  Simplified notation
  –  Remove end vertex
  –  Remove choice pseudostate construct




           Teaching Old Services New Tricks – Olga Liskin, Leif Singer, Kurt Schneider   28.03.2011   14
State Chart
  Use State Chart as a static map




          Teaching Old Services New Tricks – Olga Liskin, Leif Singer, Kurt Schneider   28.03.2011   15
2 Constructing A Wrapper


   Teaching Old Services New Tricks – Olga Liskin, Leif Singer, Kurt Schneider   28.03.2011   16
Wrapper - Conception
  Top-Down view
  –  Wrapper at first as black-box
  Insert wrapper between client and server


                             Request                             Request

            Client                           Wrapper                               Server
                             HATEOAS-
                             Response                            Response
                             Response

  –  Request forwarded
  –  Response enriched with transitions
        But not changed further




            Teaching Old Services New Tricks – Olga Liskin, Leif Singer, Kurt Schneider     28.03.2011   17
Wrapper - Conception
Main process

 Request    Wrapper                                                                         Request
                                                      Forward
                                                      request
                                                                   1
 Request                                                                                    Request
                       Enrich response                                                      Response
                                                      Calculate
                                                     application
                                                        state      2
                                                     application
                                                       state

                       <<datastore>>   transitions     Look up
                         Transition
                           model                     transitions
 HATEOAS-                                                          3
                                                        valid
 Response
 HATEOAS-                                            transitions                            Response
 Response
                                                     Construct
                                                       links
                                                                   4




              Teaching Old Services New Tricks – Olga Liskin, Leif Singer, Kurt Schneider   28.03.2011   18
Wrapper - Concrete Process Steps
Full process cycle
    HTTP/1.1 200 OK 	
  
    Last-Modified: Wed, 01 Dec 2010 	
  
                                           Local-name(/*[1]) = task
    Content-Type: application/xml	
        /task/status/text() = defined
    <task>	
  
      <id>04</id>	
  
      <name>Update Database</name>	
  
      <status>defined</status>	
  
      <parentStory>08</parentStory>	
  
    </task>




     HTTP/1.1 200 OK 	
                                                                                /task/id/text() = 04
     Last-Modified: Wed, 01 Dec 2010 	
                                          URI-Templates         /task/parentStory/text() = 08
     Content-Type: application/xml
     Link: </stories/08/tasks/04/block>;rel=”Task.block”
     Link: </stories/08/tasks/04/begin>;rel=”Task.begin”
     Link: </stories/08/tasks>; rel=”Task.allTasks”
     Link: </stories/08>; rel=”belongs_to_story”
                                                                           Task.block:    </stories/08/tasks/04/block>
     <task>	
  
                                                                           Task.begin:     </stories/08/tasks/04/begin>
       <id>04</id>	
                                                       Task.allTasks:    </stories/08/tasks>
       <name>Update Database</name>	
                                      Belongs_To_Story: </stories/08>
       <status>defined</status>	
  
       <parentStory>08</parentStory>	
  
     </task>




                  Teaching Old Services New Tricks – Olga Liskin, Leif Singer, Kurt Schneider                     28.03.2011           19
Comparison
    Implementation of backlog service
    Automated generation of wrapper (from transition model)
    Develop 2 clients to test concepts
     –  With wrapper <-> without wrapper

List links =                                           if(story.getStatus().equals(StoryStatus
      response.getHeaders().get("Link");                        .Defined)){
  for(String link : links){                                this.startButton.setEnabled(true);
    if(link.contains("story.start")){                      this.startButton.setUri("/stories/"+
      String uri = extractUri(link);                            story.getId() + "/start");
      this.startButton.setUri(uri);                        this.blockButton.setEnabled(true);
      this.startButton.setEnabled(true);                   this.blockButton.setUri("/stories/"+
    }//...                                                      story.getId() + "/block")
  }                                                      }




               Teaching Old Services New Tricks – Olga Liskin, Leif Singer, Kurt Schneider   28.03.2011   20
Conclusions
  Creation of theoretical concepts
  Development of wrapper process
  Check the concept

  Is working
  Generic
  Improves development and maintainance of clients

  Errors in model lead to invalid/missing links
  Input data is complex



           Teaching Old Services New Tricks – Olga Liskin, Leif Singer, Kurt Schneider   28.03.2011   21
Outlook
  Further research on input of data
  –  Project environment
  –  Interface descriptions (e.g. WADL) as additional source
  Allow changes of whole service API
  –  Can improve more REST aspects
  Use state charts for creation of services (not only wrappers)




            Teaching Old Services New Tricks – Olga Liskin, Leif Singer, Kurt Schneider   28.03.2011   22
Content
    Motivation
    Main Goals
    Service Example
    Terminology
    Notation for Application Models
    Conception of Wrapper Component
    Comparison
    Conclusions & Outlook



                                           Questions?


            Teaching Old Services New Tricks – Olga Liskin, Leif Singer, Kurt Schneider   28.03.2011   23

More Related Content

PDF
Sustainable Compliance For PCI DSS Standard
PDF
Meetup intro presentation
PDF
A Resource Oriented Framework for Context-Aware Enterprise Applications
PDF
IT復興円卓会議資料
PPTX
2015 State of the Industry - LOGA Don Briggs
PDF
ISPPについて
PPTX
Life Support
PDF
Xtremekeratincare
Sustainable Compliance For PCI DSS Standard
Meetup intro presentation
A Resource Oriented Framework for Context-Aware Enterprise Applications
IT復興円卓会議資料
2015 State of the Industry - LOGA Don Briggs
ISPPについて
Life Support
Xtremekeratincare

Viewers also liked (19)

PDF
Propuesta grupal
PPS
The Red Sea Crossing
PPT
English class 4
PPT
Cspd san fran2011
PDF
IT復興円卓会議資料
PDF
Xtremekeratincare.com
PDF
Presentación ingles evet2edu
PDF
Hecate, Managing Authorization with RESTful XML
PDF
S1 intro
PPTX
Wsrest13 gilherme keynote
PDF
Fulfilling the Hypermedia Constraint via HTTP OPTIONS, The HTTP Vocabulary In...
PDF
RestFS: Resources and Services are Filesystems, Too
PDF
XML Technologies for RESTful Services Development
PDF
REST and Linked Data: a match made for domain driven development?
PPTX
Trabajo de excel
PPTX
Jackson m ci583_the artist teacher identity in the classroom
PPTX
A Framework for Self-descriptive RESTful Services
PDF
REST: From GET to HATEOAS
PPTX
Roman inventions (group 9)
Propuesta grupal
The Red Sea Crossing
English class 4
Cspd san fran2011
IT復興円卓会議資料
Xtremekeratincare.com
Presentación ingles evet2edu
Hecate, Managing Authorization with RESTful XML
S1 intro
Wsrest13 gilherme keynote
Fulfilling the Hypermedia Constraint via HTTP OPTIONS, The HTTP Vocabulary In...
RestFS: Resources and Services are Filesystems, Too
XML Technologies for RESTful Services Development
REST and Linked Data: a match made for domain driven development?
Trabajo de excel
Jackson m ci583_the artist teacher identity in the classroom
A Framework for Self-descriptive RESTful Services
REST: From GET to HATEOAS
Roman inventions (group 9)
Ad

Similar to Teaching Old Services New Tricks: Adding HATEOAS Support as an Afterthought (20)

PDF
Pal gov.tutorial3.session4.rest
PPTX
REST Methodologies
PPT
Reverse Engineering Finite State Machines from Rich Internet Applications
PPT
Turning Web Applications into Web Services by Wrapping Techniques
PDF
I'll See You On the Write Side of the Web
PDF
Restful design at work v2.0
PPTX
Service approach for development Rest API in Symfony2
PDF
NDC 2011 - Building .NET Applications with BDD
PDF
BeJUG JAX-RS Event
PDF
The Art of API Design - PHP Tek 2025, Chris Tankersley
PDF
Ten Concrete Techniques to Split User Stories
PPTX
Scaling Web Services with Evolvable RESTful APIs - JavaOne 2013
PDF
What is REST?
PDF
S-CUBE LP: Data Dependency: Inferring Data Attributes in Service Orchestratio...
PPTX
Rest in practice
PDF
Writing RESTful Web Services
PPTX
REST presentation
KEY
RESTFul Services, Does it Matter Anymore?
PPTX
Ogce Workflow Suite Tg09
PDF
Great webapis
Pal gov.tutorial3.session4.rest
REST Methodologies
Reverse Engineering Finite State Machines from Rich Internet Applications
Turning Web Applications into Web Services by Wrapping Techniques
I'll See You On the Write Side of the Web
Restful design at work v2.0
Service approach for development Rest API in Symfony2
NDC 2011 - Building .NET Applications with BDD
BeJUG JAX-RS Event
The Art of API Design - PHP Tek 2025, Chris Tankersley
Ten Concrete Techniques to Split User Stories
Scaling Web Services with Evolvable RESTful APIs - JavaOne 2013
What is REST?
S-CUBE LP: Data Dependency: Inferring Data Attributes in Service Orchestratio...
Rest in practice
Writing RESTful Web Services
REST presentation
RESTFul Services, Does it Matter Anymore?
Ogce Workflow Suite Tg09
Great webapis
Ad

Teaching Old Services New Tricks: Adding HATEOAS Support as an Afterthought

  • 1. Teaching Old Services New Tricks: Adding HATEOAS Support as an Afterthought Olga Liskin, Leif Singer, Kurt Schneider {olga.liskin, leif.singer, kurt.schneider} @inf.uni-hannover.de 28.03.2011
  • 2. Content   Motivation   Main Goals   Service Example   Terminology   Notation for Application Models   Conception of Wrapper Component   Comparison   Conclusions & Outlook Teaching Old Services New Tricks – Olga Liskin, Leif Singer, Kurt Schneider 28.03.2011 2
  • 3. Motivation   Problem with web service communication: Client needs to know exactly, what a request has to look like   Many sources for errors –  Coding errors –  Invalid requests   Idea: Server includes request-information in response messages –  Which requests allowed next –  What they look like   HATEOAS   But: not many services conform to this principle Teaching Old Services New Tricks – Olga Liskin, Leif Singer, Kurt Schneider 28.03.2011 3
  • 4. Motivation Example: Service response without HATEOAS: HTTP/1.1 200 OK What can the client Last-Modified: Wed, 01 Dec 2010 17:36:02 GMT next? do Content-Type: application/xml <task> <id>208</id> <name>create GUI</name> No idea. The client <status>inprogress</status> has to know by itself. <parentStoryId>04</parentStoryId> </task> Teaching Old Services New Tricks – Olga Liskin, Leif Singer, Kurt Schneider 28.03.2011 4
  • 5. Motivation Example: Service response with HATEOAS: HTTP/1.1 200 OK Last-Modified: Wed, 01 Dec 2010 17:36:02 GMT Control elements Content-Type: application/xml directly present in Link: <stories/04/tasks/208/finish>; rel=“finish” response message. Link: <stories/04/tasks/208/block>; rel=“block” <task> <id>208</id> Now client can see <name>create GUI</name> following requests <status>inprogress</status> and how to make them <parentStory>/stories/04</parentStory> </task> …and also indicate this Teaching Old Services New Tricks – Olga Liskin, Leif Singer, Kurt Schneider 28.03.2011 5
  • 6. Main Goals   Create HATEOAS support using state charts –  Automatically generate a wrapper Service Information Generator/ Wrapper Interpreter Developer Client Wrapper Server   Prerequisite: Clear way to model network-based applications –  State Charts –  Terminology Teaching Old Services New Tricks – Olga Liskin, Leif Singer, Kurt Schneider 28.03.2011 6
  • 7. Service Example Backlog service: support agile development projects   Backlog –  contains story cards   Story Card –  One particular topic –  Different states   „definde“, „in progress“, „blocked“,…   Depend on included tasks   Task –  Story Card divided into tasks –  Different states   Changed by user Teaching Old Services New Tricks – Olga Liskin, Leif Singer, Kurt Schneider 28.03.2011 7
  • 8. 1 Modelling Network-Based Applications Teaching Old Services New Tricks – Olga Liskin, Leif Singer, Kurt Schneider 28.03.2011 8
  • 9. Terminology   Valid requests depend on current application state   What exactly is application state?   Relevant terminology: –  application   „representation of the business-aware functionality of a system“ (Fielding) –  resource state   Values of a resource‘s attributes –  application state   Requests, responses and the processing of those   E.g.: „process detail view of a story card“ Teaching Old Services New Tricks – Olga Liskin, Leif Singer, Kurt Schneider 28.03.2011 9
  • 10. Terminology 31 finished Backlog 08 24 blocked   New idea: Story –  Equivalence classes of application states   Combine „similar“ states   Determined by resource class and resource state Teaching Old Services New Tricks – Olga Liskin, Leif Singer, Kurt Schneider 28.03.2011 10
  • 11. State Chart   States –  Equivalence classes of application states –  Composite States combine states with same resource class Teaching Old Services New Tricks – Olga Liskin, Leif Singer, Kurt Schneider 28.03.2011 11
  • 12. State Chart   Transitions –  Possible change of application state   triggered by new client request –  Target state reached in case of success   Transitions between Simple States Teaching Old Services New Tricks – Olga Liskin, Leif Singer, Kurt Schneider 28.03.2011 12
  • 13. State Chart   Transitions between Composite States –  More precise information about control flow necessary –  Outgoing transition:   Transition possible from all sub-states –  Incoming transition:   Client requests a resource of particular class   Sub-state can only be determined at runtime   choice-pseudostate Teaching Old Services New Tricks – Olga Liskin, Leif Singer, Kurt Schneider 28.03.2011 13
  • 14. State Chart   Simplified notation –  Remove end vertex –  Remove choice pseudostate construct Teaching Old Services New Tricks – Olga Liskin, Leif Singer, Kurt Schneider 28.03.2011 14
  • 15. State Chart   Use State Chart as a static map Teaching Old Services New Tricks – Olga Liskin, Leif Singer, Kurt Schneider 28.03.2011 15
  • 16. 2 Constructing A Wrapper Teaching Old Services New Tricks – Olga Liskin, Leif Singer, Kurt Schneider 28.03.2011 16
  • 17. Wrapper - Conception   Top-Down view –  Wrapper at first as black-box   Insert wrapper between client and server Request Request Client Wrapper Server HATEOAS- Response Response Response –  Request forwarded –  Response enriched with transitions   But not changed further Teaching Old Services New Tricks – Olga Liskin, Leif Singer, Kurt Schneider 28.03.2011 17
  • 18. Wrapper - Conception Main process Request Wrapper Request Forward request 1 Request Request Enrich response Response Calculate application state 2 application state <<datastore>> transitions Look up Transition model transitions HATEOAS- 3 valid Response HATEOAS- transitions Response Response Construct links 4 Teaching Old Services New Tricks – Olga Liskin, Leif Singer, Kurt Schneider 28.03.2011 18
  • 19. Wrapper - Concrete Process Steps Full process cycle HTTP/1.1 200 OK   Last-Modified: Wed, 01 Dec 2010   Local-name(/*[1]) = task Content-Type: application/xml   /task/status/text() = defined <task>   <id>04</id>   <name>Update Database</name>   <status>defined</status>   <parentStory>08</parentStory>   </task> HTTP/1.1 200 OK   /task/id/text() = 04 Last-Modified: Wed, 01 Dec 2010   URI-Templates /task/parentStory/text() = 08 Content-Type: application/xml Link: </stories/08/tasks/04/block>;rel=”Task.block” Link: </stories/08/tasks/04/begin>;rel=”Task.begin” Link: </stories/08/tasks>; rel=”Task.allTasks” Link: </stories/08>; rel=”belongs_to_story” Task.block: </stories/08/tasks/04/block> <task>   Task.begin: </stories/08/tasks/04/begin> <id>04</id>   Task.allTasks: </stories/08/tasks> <name>Update Database</name>   Belongs_To_Story: </stories/08> <status>defined</status>   <parentStory>08</parentStory>   </task> Teaching Old Services New Tricks – Olga Liskin, Leif Singer, Kurt Schneider 28.03.2011 19
  • 20. Comparison   Implementation of backlog service   Automated generation of wrapper (from transition model)   Develop 2 clients to test concepts –  With wrapper <-> without wrapper List links = if(story.getStatus().equals(StoryStatus response.getHeaders().get("Link"); .Defined)){ for(String link : links){ this.startButton.setEnabled(true); if(link.contains("story.start")){ this.startButton.setUri("/stories/"+ String uri = extractUri(link); story.getId() + "/start"); this.startButton.setUri(uri); this.blockButton.setEnabled(true); this.startButton.setEnabled(true); this.blockButton.setUri("/stories/"+ }//... story.getId() + "/block") } } Teaching Old Services New Tricks – Olga Liskin, Leif Singer, Kurt Schneider 28.03.2011 20
  • 21. Conclusions   Creation of theoretical concepts   Development of wrapper process   Check the concept   Is working   Generic   Improves development and maintainance of clients   Errors in model lead to invalid/missing links   Input data is complex Teaching Old Services New Tricks – Olga Liskin, Leif Singer, Kurt Schneider 28.03.2011 21
  • 22. Outlook   Further research on input of data –  Project environment –  Interface descriptions (e.g. WADL) as additional source   Allow changes of whole service API –  Can improve more REST aspects   Use state charts for creation of services (not only wrappers) Teaching Old Services New Tricks – Olga Liskin, Leif Singer, Kurt Schneider 28.03.2011 22
  • 23. Content   Motivation   Main Goals   Service Example   Terminology   Notation for Application Models   Conception of Wrapper Component   Comparison   Conclusions & Outlook Questions? Teaching Old Services New Tricks – Olga Liskin, Leif Singer, Kurt Schneider 28.03.2011 23