Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

There are no standard REST-based APIs associated with task services. Most frequently, these are implemented in the REST RPC paradigm, where the name of a task service is included in the request URL, followed by query parameters that pass arguments to the service; e.g. /nameOfTaskService?param1=value&param2=value...

However, for consistency with the resource-oriented, REST-based APIs above, we might instead model task services as resources. For some potential patterns that we might use for doing so, see "Handling arbitrary actions" in RESTful Service - Ajax Patterns:

  • Where you're trying to transform state, have the client compute the new state and PUT a specification of the desired state - a standard update operation. For updates that are complex or entail business logic, you can provide a read-only service - accessed with GET queries - to help the client compute the new state.
  • You can POST a message to the resource in question, for example, POST a "pause" message to a URL representing the printer.
  • The server can expose a stateless "processor" resource to perform the action, e.g. a printer controller, and have clients POST command-like messages there, with URLs referencing the resources to be acted upon.

Another resource-oriented pattern has been used successfully by Rob Heittman:

The classic example of something very hard to implement without some server side state is an e-commerce shopping cart. There are a handful of examples on the web of a "purely RESTful shopping cart," but they tend to be a bit odd ...

But one way to RESTify this model, without changing it completely, is to deconstruct the idea of the "session" a bit. Instead of having one generalized server-side bag of state (the JSP/Servlet style HttpSession), which can only be accessed using server-side code, the client can use RESTful operations to create a needed resource on the server (e.g. a ShoppingCartResource); then these resources may be exposed back to the creator using RESTful patterns.

This hypothetical ShoppingCartResource would have a URI and ... representations that can be PUT, GET, etc. ... Now you have your shopping cart abstracted in a way that you can work with it on the server side using internal requests ... OR work with it on the client side using an Applet, Flex/Flash RIA, GWT, or AJAX application.

References

RESTful Web Services

...