I'm trying to read some information with a REST-Service that uses chunk-encoding.
String encodedURL = URLEncoder.encode(url, "UTF-8");
WebClient client = org.apache.cxf.jaxrs.client.WebClient.create(encodedURL).accept("text/html");
Response response = client.get();
The response contains a status, metadata and the entity. The metadata contains the following information:
{Date=[Thu, 13 Oct 2011 13:27:02 GMT], Vary=[Accept-Encoding, User-Agent], Transfer-Encoding=[chunked], Keep-Alive=[timeout=15, max=100], Content-Type=[text/html; charset=charset=UTF-8], Connection=[Keep-Alive], X-Pad=[avoid browser bug], Server=[Apache/2.2.3 (Linux/SUSE)]}
and the entity contains an instance of the type sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.
I the past, I've been using the following line of of code, to get the entire result string:
String resultString = client.get(String.class);
But somehow, this line throws an exception:
.Problem with reading the response message, class : class java.lang.String, ContentType : text/html;charset=charset=UTF-8. org.apache.cxf.jaxrs.client.ClientWebApplicationException: .Problem with reading the response message, class : class java.lang.String, ContentType : text/html;charset=charset=UTF-8.
... caused by:
Caused by: java.io.UnsupportedEncodingException: charset=UTF-8 at sun.nio.cs.StreamDecoder.forInputStreamReader(Unknown Source) at java.io.InputStreamReader.(Unknown Source) at org.apache.cxf.helpers.IOUtils.toString(IOUtils.java:180) at org.apache.cxf.helpers.IOUtils.toString(IOUtils.java:166) at org.apache.cxf.jaxrs.provider.PrimitiveTextProvider.readFrom(PrimitiveTextProvider.java:51) at org.apache.cxf.jaxrs.client.AbstractClient.readBody(AbstractClient.java:435) ... 49 more
Is there a straightforward solution to the get the entire content of the response?
Thank you!
kon