Hi

When creating web clients, you can do
WebClient.create("http://localhost:8080/books";,
Collections.singletonList(reader));

If you have different types returned by the same WebClient, then just reset
the entity class on the reader before
making a call....

Cheers, Sergey

On Fri, Jan 21, 2011 at 4:34 PM, Dan King <[email protected]> wrote:

> Thanks for the help; however, I do have a few follow-up questions:
>
> 1. Can "ResponseReader" be used with "WebClient" objects or is its use
> limited
> to client proxies only? i.e.
>
>
> ResponseReader reader = new ResponseReader();
> reader.setEntityClass(Book.class);
>
> JAXRSClientFactory.create("http://localhost:8080/books";, BookStore.class,
> Collections.singletonList(reader));2. Where can I find examples of custom
> message body reader/writer implementation examples? I've searched
> everywhere and
> found nothing that helps in understanding how to implement a custom one.
>
> 3. I checked the example Glenn suggested, however that example does NOT use
> "ResponseReader". The method "useSimpleProxy" in "RESTClient.java", creates
> a
> client proxy from which it retrieves a collection of person objects; it
> never
> deals with a "Response" object. Did I miss something in the example?
>
> Thanks.
>
> -Dan
>
> ----- Original Message ----
>
> > From: Sergey Beryozkin <[email protected]>
> > To: [email protected]
> > Sent: Fri, January 21, 2011 6:37:54 AM
> > Subject: Re: How to convert response input stream to java object
> >
> > ResponseReader is a custom MessageBodyReader<Response> handler which  is
> > registered on the client side, it allows to do a safe type casting, such
>  as
> >
> > Response response = webClient.get();
> > Book book =  (Book)Response.getEntity();
> >
> > It's possibe to write your own custom  Response reader with any CXF
> version
> > supporting the client api, but using the  ResponseReader makes it
> simpler...
> >
> > Please check the demo Glen linked  to.
> >
> > Sergey
> >
> > On Fri, Jan 21, 2011 at 4:08 AM, Glen Mazza <[email protected]> wrote:
> >
> > > I  think ResponseReader, recently introduced in CXF 2.3.1, is your
>  friend.
> > >
> > > If you go to the Talend Service Factory (CXF wrap)  Examples[1], under
> > > examples/jaxrs-advanced/client/..../RESTClient.java,  method
> useSimpleProxy()
> > > has it.
> > >
> > > Glen
> > >
> > > [1]  http://www.talend.com/resources/documentation.php#SF
> > >
> > >
> > >  --
> > > Glen Mazza
> > > Software Engineer, Talend  (http://www.talend.com)
> > > blog:  http://www.jroller.com/gmazza
> > >
> > >
> > >
> >
>
>
>
>

Reply via email to