WADLing in Jersey
With the latest changes to Jersey you can now get information on such dynamic resources by GETing the resource with an Accept: application/vnd.sun.wadl+xml header that specifies that you want WADL rather than another representation. The Jersey runtime will inspect the object returned by the subresource locator and dynamically generate a WADL description.
Now WADL finally gets interesting (see also this discussion).
Hm, is this really RESTful? I’ve always thought each representation should ‘represent’ the actual state/content of a resource and not a bunch of meta data. Isn’t a WADL file another resource, a sub-resource so to say?
Good point. Yes, you may be right — I’m not sure. If the WADL describes the resource sitting at X, I feel it’s reasonable to retrieve it from X. On the other hand, maybe it would be better to return a link instead.
I have been toying with the three different approaches of using OPTIONS, GET or an additional URI, as presented here.
Part of the problem with the latter two is that they can either interfere with the application (what if WADL is stored as the media entry of an atom collection?) or assumes additional server-side framework knowledge (of the URI, since it seems silly to bootstrap and traverse parallel hypermedia).
The OPTIONS method seems, technically, the right approach but of course OPTIONS is to put it mildly under utilized.
Tis all still a bit experimental which is why we have currently implemented support for GET and OPTIONS.