28 March 2005

Parallel Universe

I've reached the chapter that talks about WS-Addressing and the WS-Resource Framework (chapter 8 in Building Web Services with Java). Apart from having a hard time getting my ahead around the authors' concepts of stateful and stateless resources, I couldn't help but feel like I was traveling through a parallel universe. I was left with the impression that the whole WS-Resource framework is an attempt to duplicate what we already have in the existing web - but crammed inside of the WS-* world and using none of the existing mechanics already available. It's as if their charter was to reinvent the web without using any of the existing technologies - and to make sure it doesnt interoperate with the existing web.

I've also noticed that as I've been reading I keep finding myself wishing that some of the things in WS-* could be extracted and applied to a more RESTful environment. In particular, I keep wondering whether having something like WSDL would be useful.

Let's say that I have a real estate 'application' that deals with real estate listings. A listing resource has state that includes things like an address, a listing agent, a homeowner, a description, a listing status and a unique identifier. In order for client software to effectively use my 'application', I need to be able to define how the client can interact with resources of this type (e.g., listing resources). It seems to me that in order to construct a client that can interact with a particular type of resource, I need to know the following things:
  1. the resource's state or data model; i.e., what elements make up a listing resource's state (I guess this would essentially be a type definition)
  2. a list of valid transformations that can be applied to a listing resource; i.e., what parts of the resource's state can I change, and how do I go about effecting those changes
  3. a definition of valid values for the various parts of the resource's state (maybe this is really part of the data model)
For web services, this kind of stuff appears to be mostly defined via WSDL. But if I want something more RESTful, I'm not sure what the answer might be. For that matter, I'm not even sure I'm asking the right question.

I'm pretty sure that the first and last items are reasonable things to want. Its the middle one that I'm not so sure of. I can't help but think that I'm effectively trying to define new operations that can be performed on a resource, and that would seem to violate the constrained interface.

I did look at RDF Forms, but I'm not sure whether that's what I want or not. It seems like something is missing, but maybe I'm just making it more complicated than it needs to be

2 comments:

Mark Baker said...

RDF Forms does a lot of this, but some of what you seem to need is implicit too. For example, you don't need any information other than a URI and a GET response to tell you that in order to change the state of the thing, you can PUT a modified version of that representation back. It may or may not have the desired effect (e.g. authorization may be required, or the resource isn't editable), but at least the meaning of both the request and response messages is unambiguous.

Mark Baker said...

P.S. that's also why RDF Forms doesn't support PUT... though I suppose it could to cover the edge cases, for example where you have to PUT in a format that's different from what you GET.