users@jersey.java.net

Re: [Jersey] Client java stubs with Jersey

From: xworker <andreas_at_onecoder.com>
Date: Wed, 2 Sep 2009 03:20:10 -0500 (CDT)

Paul Sandoz wrote:
>
> On Sep 2, 2009, at 9:31 AM, xworker wrote:
>>
>> Hi
>>
>> I'm using Jersery for ws in my project. I've got a JPA backend with
>> lots of
>> entitys. Question:
>>
>> How do I generate java POJO stubs from my Jersey ws? For SOAP I was
>> able to
>> generate client-side stubs, but not for REST?
>
> I advise against creating Java client stubs from Java server artifacts
> because they make a tight coupling between client and server-side code
> (but see later).
>
>
>>
>> Frontend is a backingbean with JSF pages.
>>
>> <code>
>> wr =
>> client.resource("http://localhost:8080/pe-backend/resources/
>> activities");
>> activityList = wr.get(new GenericType<List<Activity>>() {
>> });
>> </code>
>>
>> How shouold my backingbean know what Activity is?
>>
>
> Human readable documentation of the service to be read by the
> developer. Because the client is separated from the server you can
> also do:
>
> wr =
> client.resource("http://localhost:8080/pe-backend/resources/activities
> ");
> activityArray = wr.get(Activity[].class);
>
> or perhaps use a different version of Activity (JAXB is somewhat
> flexible in terms of consuming documents with additional XML it does
> not understand). Or use some XPath on DOM.
>
> WADL can be used to help create the human readable documentation that
> can be served as part of the service. Jersey dynamically creates a
> WADL description of the service, see also here:
>
> http://wikis.sun.com/display/Jersey/WADL
>
> If you really want static client stubs you could use the wadl2java
> facility available from:
>
> https://wadl.dev.java.net/
>
> Paul.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>
>

Hi

Thanks for the swift reply. I have used the wadl2java tool, but it generates
an Endpoint class wich my IDE (netbeans) doesn't like. It finds strange
errors on every line. For example:

Error postAs(javax.activation.DataSource) is already defined in
xxx.ws.Endpoint.Industries Endpoint.java

and

Error xxx.ws.Endpoint.Industries.IndustryId.ActivitySet.ActivityId is
already defined in xxx.ws.Endpoint.Industries.IndustryId.ActivitySet
Endpoint.java


The reason want entitys is that I use them on my JSF pages, for examples in
datatables.


-- 
View this message in context: http://n2.nabble.com/Client-java-stubs-with-Jersey-tp3565216p3565415.html
Sent from the Jersey mailing list archive at Nabble.com.