users@jersey.java.net

Re: WADL and JavaScript generation

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Wed, 02 Jan 2008 15:03:23 +0100

Hi Gérald,

Gérald Quintana wrote:
> Dear Jersey users,
>
> I am currently evaluating JAXRS which looks very promising even if not
> yet finished.
>
> I managed to generate RESTful web service stubs from a WADL file using
> the wadl2java tool.
>

Great.


> Question 1: I wondered whether it was possible to generate WADL
> descriptor from Java sources using an Ant script or command line tool?
>

Originally we did have a compile time tool to generate WADL for the root
resource classes. But we have recently removed all the compile
time/deploy time configuration and now it is purely dynamic where by
default no configuration is required.

We have discussed about having doclet for generating nice JavaDocs from
the Java sources. As part of that we would also like to reintroduce an
ant task specifically for WADL generation by dynamically looking up the
root resource classes present in a class path (and reusing much of code
that operates dynamically at runtime). Would you be interested and have
time to help out on developing such an ant task? My knowledge of the ant
API is limited...

Note that such static analysis will not necessarily get all the WADL for
all resources you have implemented. If all resources are root resources
then it will work, but if you have root resources that return
sub-resources then no WADL will be defined until those sub-resources get
instantiated i.e. the whole application cannot be know at compile time.


> I would like to generate web service client stubs to ease unit
> testing, I wish I could avoid the HTTP request creation and
> management. So I imagined I could do something like Service Impl
> (Java+Jersey) --> WADL description (XML) --> Service Stub (Java)
>
> Previously, I tested SOAP web services with JAXWS like this and was
> satisfied by such a solution.
>

Agreed that this can work very well but can in some cases can unduly
bind the client and service so that when the service interface changes
the client breaks.

Our approach in general has been pragmatic and to realize that
developers who are familiar/comfortable with the static WSDL approach
can still do so with WADL but for those that want very loosely coupled
it is possible to use WADL more dynamically (see response to next
question).


> Question 2: I saw that NetBeans 6 + JAXRS plugin was able to generate
> a Java Script Client. I wondered whether a tool to generate JavaScript
> stubs existed (wadl2javascript or something like that)
>

I am not sure. IIRC the NetBeans are still on vacation until next week,
so we may have to wait until they return for a definitive answer.

As i understand it the JavaScript code is reasonably dynamic and obtains
the WADL from a running service to create HTML to test the service. But
i am not sure of the dividing line between static and dynamic
processing. I suspect that the code may be modified to be even more
dynamic now that it is possible to get the WADL for any resource and not
just the root resources.

Paul.

> Thanks for your help,
> Gerald
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>

-- 
| ? + ? = To question
----------------\
    Paul Sandoz
         x38109
+33-4-76188109