Your browser doesn't support the features required by impress.js, so you are presented with a simplified version of this presentation.

For the best experience please use the latest Chrome, Safari or Firefox browser.


Composition of RESTful Services

Prof. Cesare Pautasso
http://www.pautasso.info
cesare.pautasso@usi.ch
@pautasso

REpresentational State Transfer

REST defines the architectural style of the Web

  1. Resource Identification through URI
  2. Uniform Interface for all resources:
    • GET (query the state, read-only)
    • PUT (Create/Update a resource, idempotent)
    • DELETE (Delete a resource, idempotent)
    • POST (Create/Access a resource)
  3. Multiple representations of the same resource
  4. Hyperlinks model resource relationships and valid state transitions for dynamic protocol description and discovery

REST Architectural Elements

  • User Agent
  • Proxy
  • Gateway
  • Origin Server
  • Gateway
  • HTTP Connector
  • Cache

REST middleware is primarily designed to scale a single server, which may need to service a large number of clients

A Composite REST service provides an aggregated view over the state of multiple REST services

The behavior of /C is defined by
composing /R and /S

The composite resource /C only aggregates
the state of its components /R and /S

The composite resource /C augments or
caches the state of its components

The composite representation C refers to its component resources /R and /S via hyperlinks

A composite representation is interpreted by the client that follows its hyperlinks and aggregates the state of the referenced component resources

A composite representation may be retrieved from a composite service

Example: DoodleMap

Vote to choose a meeting place based on its geographic location

Composite REST Service

Compose Yahoo! Local Search with Doodle

Composite REST Service

Create a new poll using the locations

Composite Representation

Demo

Composing REST Services

How to program a composite resource?

Business Process Modeling

  • JOpera (RESTful BPM engine)
  • BPEL for REST
  • BPMN for REST

Scripting Languages

  • S - REST service composition for JS

The S Scripting Language

for Scalable, Stateful, RESTful Services

PPOPP 2012

S: Hello World

service S { 
  res '/hello' on GET { 
  //handle GET request
    respond 'World!'; 
  }
}

Request handlers contain any JavaScript code (with some S extensions)

S: Proxy

service Proxy { 
  res '/hello1' on GET { 
    respond get '/hello2'; 
  }
  res '/hello2' on GET { 
    respond get 'http://api.inf.usi.ch/'; 
  }
}

S: Composition

service Composition { 
  res '/search' on GET { 
    res a = 'http://www.bing.com/?q=$query';
    res b = 'http://www.google.com/?q=$query';
    respond a.get + b.get; 
  }
}

S: Stateful Services

service Stateful { 
 res '/hello' {
  state s = 'World'
  on GET { 
    respond 'Hello ' + s
  }
  on PUT { 
   s = $name
  }
 }
}

S: DoodleMap

service DoodleMap { 
 res '/doodlemap' {
  state id = 0;
  on POST { 
res yls = 'http://local.yahooapis.com/search' + '?query=$query&zip=$zip'; res doodle = 'http://doodle-test.com/.../polls'
var local = yls.get; var pollurl = doodle.post(xml_format(local,$title));
state ui_html[id++] = render('GoogleMap', local, pollurl); res id { on GET { respond ui_html[$id]; } }
respond { 302: {"Location": "/doodlemap/"+id}} var timer = setInterval(function() { var pollState = res(pollurl).get; var participants = countParticipants(pollState); if (participants == $maxParticipants) { res(pollurl).put("closed"); clearInterval(timer); } },1000); } } }

Conclusion

  • REST service composition extends the role of intermediary to support the aggregation of multiple distributed resources
  • REST service composition takes advantage of hypermedia to shift some of the composition work (and state) to the client (Composite Representation)
  • REST composition fits very well with Business Process Management (JOpera, BPEL/BPMN for REST)
  • S is a RESTful extension to JavaScript to
    script stateful and composite services

References

  • Roy Fielding, Architectural Styles and the Design of Network-based Software Architectures, University of California, Irvine, 2000
  • Leonard Richardson, Sam Ruby, RESTful Web Services, O‚ÄôReilly, May 2007, ISBN 0-596-52926-0
  • Jim Webber, Savas Parastatidis, Ian Robinson, REST in Practice: Hypermedia and Systems Architecture, O'Reilly, 2010
  • Daniele Bonetta, Achille Peternier, Cesare Pautasso, Walter Binder, S: a Scripting Language for High-Performance RESTful Web Services, 17th ACM SIGPLAN Symposium on Principles and Practice of Parallel Programming (PPoPP 2012), New Orleans, LA, USA, February 2012
  • Cesare Pautasso, Erik Wilde, Push-Enabling RESTful Business Processes, 9th International Conference on Service Oriented Computing (ICSOC 2011), Paphos, Cyprus, December 2011
  • Cesare Pautasso, BPMN for REST, In Proceedings of the 3rd International Workshop on BPMN (BPMN 2011), Lucerne, Switzerland, November 2011
  • Guy Pardon, Cesare Pautasso, Towards Distributed Atomic Transactions over RESTful Services, In: REST: From Research to Practice, Springer 2011
  • Cesare Pautasso, Composing RESTful Services with JOpera, In: Proc. of the International Conference on Software Composition (SC2009), July 2009, Zurich, Switzerland.
  • Cesare Pautasso, RESTful Web Service Composition with BPEL for REST, Data & Knowledge Engineering, Volume 68, Issue 9, September 2009, Pages 851-866
  • Erik Wilde, Cesare Pautasso, (eds.) REST: From Research to Practice, Springer, 2011
  • Thomas Erl, Benjamin Carlyle, Cesare Pautasso, Raj Balasubramanian, SOA with REST: Principles, Patterns & Constraints for Building Enterprise Solutions with REST, Prentice Hall, 2012

Use a spacebar or arrow keys to navigate