Stateful Web Services
Thursday, 27 October 2005
While back end code tends to prefer coarse grained interaction, front end user interfaces prefer fine-grained interaction. The reasons are:
- Data validation
- Capability validation
- Long forms
disabling buttons that user doesn’t have rights to, rather than throw exception at the end when user tries to commit the operation
There are times when user interaction need to be broken down into a sequence.
This presents a common dilemma to those designing the appropriate SOA interface. The options are to either use some kind of session (similar to HTTP Sessions), or turn the service into a Corba-style object, where the client manipulates a live-object over several interactions.
A good style that I have observed is with Web Mail interfaces. Attaching documents to a webmail requires a temporary creation of a resource on the server. The browser client proceeds to keep on interacting with the temporary resource, but nothing is committed to the SMTP back-end. In this case:
- statefulness is a necessary evil, but it is mitigated by the service providing a fool-proof interaction sequence.
- there is no guarantee of two-phase commit. The final “Send” operation still works as a coarsed grained interaction with the back-end.
- since the back end interacts only with the resource located at the server itself, there is no network bottleneck
- in addition, one doesn’t have to worry about the client doing the equivalent of hitting the submit button twice, i.e. reliable HTTP
- the resource can have a limited lifetime, i.e. a lease, and can be cleaned up if the user has not committed it by the time the lease expires
No. 1 — October 27th, 2005 at 1:55 pm
A Stateful Subtlety
A post over at the counterpoint blog brings up Stateful Web Services.
After reading it over a few times, I believe the post asserts that:
1. SOA and Web Services lend themselves towards a course-grained API. (Which I think it means WS-*).
2. But user…
No. 2 — October 27th, 2005 at 4:41 pm
Thanks for your comments. Yes, I was referring to REST. :)
Instead of saying statefulness is a necessary evil, what I really meant was:
if you really have to hold state, then
a) shield the back end from this detail by having a proxy hold state, and
b) then try your darndest to limit the interactions with the proxy to those which have no side-effects.
c) If they have to have side-effects, then present a tight script so that client can only talk to the proxy in a particular order
If I can find the right words, I’ll post more on why having less flexibility is important.