The problem with the following code is, if the resource is not found using the
get call, it throws an IOException as follows. In this case I can't get the
response from the webclient right after the get call. Any suggestions?
Caused by: java.io.IOException: HTTP response '404: Not Found'
at
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:2187)
at
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:2134)
at
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1988)
-----Original Message-----
From: Sergey Beryozkin [mailto:[email protected]]
Sent: Monday, March 26, 2012 11:01 AM
To: [email protected]
Subject: Re: How to parse string from javax.ws.rs.core.Response?
Hi
On 26/03/12 16:49, Ganesan, Chandru wrote:
>
> Hi
>
> I'm using a simple rest client that executes a query and gets String
> response. I'm using WebClient.get(...) to execute the REST call as follows.
>
> Response jsonResponse = oneViewWebClient.get();
>
> I do see the response code of 200 in the jsonResponse object but unable to
> access the string value from the returned response. In this case, I'd like to
> parse the response using jsonResponse.getEntity(..) I'm not using JAXB to
> deserialize the object, since it's a string is there a simple method to parse
> the response?
>
String str = oneViewWebClient.get(String.class);
should do it, you can also get the Response:
oneViewWebClient.getResponse()
Cheers, Sergey
> Thanks
> Chandru
>
>
--
Sergey Beryozkin
Talend Community Coders
http://coders.talend.com/
Blog: http://sberyozkin.blogspot.com