Hi

On Mon, Jan 24, 2011 at 11:17 PM, Dan King <[email protected]> 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

Reply via email to