cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sergey Beryozkin <>
Subject Re: How to convert response input stream to java object
Date Tue, 25 Jan 2011 09:39:15 GMT

On Mon, Jan 24, 2011 at 11:17 PM, Dan King <> wrote:

> > ... With the WebClient you can do
> >
> > Book book =  wc.get(Book.class)
> > // returns the last Response, no remote invocation is  done
> > Response r = wc.getResponse();
> This is what I'm currently doing; I thought of changing to using
> "ResponseReader" since it seemed "cleaner" to check the response status
> before
> attempting to read the message body. Is there any value in changing
> approaches?

wc.get(Book.class) will throw the ServerWebApplicationException in case of
the status >= 400. Currently 'null' will be returned in case of redirects,
unless CXF is configured to do the auto-redirects.

wc.getResponse(); will return the Response no matter what :-), unless a
client side error occurs, in which case you'll
get ClientWebApplicationException.

I guess ResponseReader can give a possibility to work with explicit
Responses consistently irrespectively whether proxies or WebClients are used
and indeed, as you said, it makes it easier to follow the 'check status
first' approach...

Cheers, Sergey

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message