A little while back there was a lot of pontificating on about web service description languages in the blogosphere. I avoided weighing in partly because its a complex topic and partly because of lack of time. A recent thread on TSS and a commenter have prompted me to get back to actually writing this post though. So here we go…
RESTful services do not need an interface description language. They have a defined uniform interface. This is fundamental.
There are some things which you do need to know to interact with a service though:
1. Documentation of the entry points into the hypertext engine.
This is to some extent solved. This is what OpenSearch is for.
2. What types of media types the resource supports.
On the retrieval side this can be done with a HEAD request and the Content-Type header. On the POST/PUT side, you can use a HEAD plus the Accept header.
3. What methods are available to use on a resource.
Use OPTIONS.
4. A description of the media type.
That is we need a description of the data, not the interface. This item is where I feel there is a large void.
Lets say I have an XML schema for a purchase order. And then I have my media type application/vnd.acme-purchase-order. I need a way to associate these two.
For those who tell me to look in the documentation: that isn’t a good enough answer. We need a machine to machine way to do this. Also, why are the first 3 items OK to do with machines and not this one? Seems rather silly to me.
I know of two possible options for solving this:
1. Define an HTTP header which points to a document which provides a media type to description mapping. Then when you HEAD a resource, you get a link to the description. Then you get a document which associates a media type with a link to a description of that resource.
2. Shove it in the content type header a la James’ proposal (see the comments). Ideally though I’d like it to mesh better with the accept header.
3. Create a document which creates a link between the media type and it’s description, then point people to it. The document basically just needs to have something like <link rel=”application/vnd.acme-foo” href=”foo.xsd”/>. (For bonus points it could have links to the OpenSearch documents too…)
The larger question
The larger question in my mind is if this is all a little.. obtuse. While its kind of cool architecturally, there is a lot of resource scanning going on here to use your service. There is a lot to be said for having a description of your service all in one place like WADL does. Users will be less confused (have you tried teaching what REST is to anyone lately?). Who wants to go around and do a bunch of HEAD/OPTIONS requests while trying to figure out how to interact with a service? You can document your service in one place (which you need to do anyway). You can think more coherently about your service as its all defined in one place. You can give it to something like Jersey and get some service stubs generated (*gasp* who would want to do something this evil!?). And probably a bunch more stuff I’m not thinking of.
Conclusions
Does REST need an interface description language? No. That’s an oxymoron.
Do RESTful services need a way for you to determine how schemas and media types align? Yes.
Would having one document to describe a set of resources be really handy? Yes.
Is this document an IDL? No.
Should you forget about IDLs then and give resource description languages a second chance because anyone who doesn’t at least admit they are somewhat useful is clearly being one sided about this? YES.
In short, I think that having a resource description language is extremely useful from a practical standpoint and I generally support the effort to come up with one. It just simplifies my life too much for me to not want it.
Update: fixed a grammar problem or two and added a third way to discover media type descriptions.