チャンクエンコーディングを使用するRESTサービスでいくつかの情報を読み込もうとしています。
String encodedURL = URLEncoder.encode(url, "UTF-8");
WebClient client = org.apache.cxf.jaxrs.client.WebClient.create(encodedURL).accept("text/html");
Response response = client.get();
応答には、ステータス、メタデータ、およびエンティティが含まれます。メタデータには次の情報が含まれています。
{Date =[2011年10月13日木曜日13:27:02GMT]、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 = [ブラウザのバグを回避]、Server = [Apache / 2.2.3(Linux / SUSE)]}
エンティティには、sun.net.www.protocol.http.HttpURLConnection$HttpInputStreamタイプのインスタンスが含まれています。
私は過去に、次のコード行を使用して、結果文字列全体を取得していました。
String resultString = client.get(String.class);
しかし、どういうわけか、この行は例外をスローします:
。応答メッセージの読み取りに問題があります。クラス:クラスjava.lang.String、ContentType:text / html; charset = charset=UTF-8。org.apache.cxf.jaxrs.client.ClientWebApplicationException:。応答メッセージの読み取りに問題があります。クラス:クラスjava.lang.String、ContentType:text / html; charset = charset=UTF-8。
... のせいで:
原因:java.io.UnsupportedEncodingException:charset = UTF-8 at sun.nio.cs.StreamDecoder.forInputStreamReader(Unknown Source)at java.io.InputStreamReader。(Unknown Source)atorg.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
応答のコンテンツ全体を取得するための簡単な解決策はありますか?
ありがとうございました!
kon