users@wadl.java.net

Re: Converting JAX-RS resources to WADL

From: Marc Hadley <Marc.Hadley_at_Sun.COM>
Date: Mon, 29 Jun 2009 09:01:45 -0400

On Jun 29, 2009, at 7:33 AM, Sergey Beryozkin wrote:
>
> I have few questions about converting JAX-RS resources to WADL.
>
> 1. How to represent recursive relationships ?
> For ex :
> @Path("/bar")
> public RootResource() {
>
> @GET
> public State get() {}
>
>
> @Path("/sub")
> public RootResource asSubresource() {
> return this;
> }
> }
>
> I was rthinking about something like :
> <application><resources>
> <resource id="root">
> <resource path="/bar">
> <method name="GET">...</method>
> </resource>
> <resource path="/bar/sub" idref="root"/>
> </resources></application>
>
> what is the right way to do it ?
>
The idref isn't a WADL attribute. In Jersey we support partial WADLs
so for subresource locators we just return an empty <resource
path="..."/> and then the client can GET the partial WADL for the
subpath later. I covered this in a blog entry:

http://weblogs.java.net/blog/mhadley/archive/2007/12/wadling_in_jers.html

> 2. Multiple consumes/produces types on a given method :
>
> @GET Produces("application/xml, application/json") public State
> get() {}
>
> does it translate to two GET methods with the one representation
> element in each one or a single GET element with 2 representations
> elements ?
>

Either is valid but the canonical way is one get method with two
sibling representations.

Marc.