Creating an Extreme Web Service in N Easy Steps
- Start with a SOAP service. This is not strictly necessary but will
probably be required by your buzzword-chasing boss. I don't want to get anyone
fired so you may have to humour him.
- Determine the implicit objects in the service. For instance if you
have getPurchaseOrder, getInvoice then pretty clearly you have Purchase Order
and Invoice objects. These will become resources. Define XML Schemas for them
if you don't already have them (or use one compound schema).
- Create a script, servlet or JSP for each kind of object. Give it a
GET method that returns XML conforming to the schema. Give it a PUT method that
updates the underlying database for every transaction. Give it a DELETE method
for removing relevant data from the database.
- Move the appropriate SOAP methods to the POST method for each
resource type handling script.
- Replace each set of getXXX, setXXX and deleteXXX methods with a
single hyperlink from the containing resource to the contained resource.
- Replace any method that adds a contained resource to a container with
POST. It doesn't really matter if the contained resource can have multiple
kinds of children. The same method suffices.
- Also replace any method that mutates the current state (e.g.
increments by one or doubles, or appends) with POST. If doing this conflicts
with the method above then conside refactoring your resources so that the
container part is separate from the content part.
- Replace any search-like methods with GET-queries.
- If there are resources that are only reachable through GET-queries
(not hyperlinks), consider making some form of hyperlink-based table of
contents for them to allow them to be discovered by clients that want to
discover them rather than search for them.
- Consider the remaining methods: can they easily be construed as also
dealing with implicit resources? For instance, a LOCK method could be replaced
with a LOCK resource and a hyperlink. If you can't figure out how to translate
your remaining SOAP messages, you can either just accept that your service is
not Extremely Extreme or you can post to rest-discuss for some advice (which
might influence a later version of this document).