我正在使用jersey客户端将文件发布到REST URI,该URI返回响应为json.我的要求是将响应按原样(json)读取到字符串.
以下是将数据发布到Web服务的代码段.
final ClientResponse clientResp = resource.type(
MediaType.MULTIPART_FORM_DATA_TYPE).
accept(MediaType.APPLICATION_JSON).
post(ClientResponse.class, inputData);
System.out.println("Response from news Rest Resource : " + clientResp.getEntity(String.class)); // This doesnt work.Displays nothing.
Run Code Online (Sandbox Code Playgroud)
clientResp.getLength()有281个字节,这是响应的大小,但clientResp.getEntity(String.class)什么都不返回.
任何想法在这里可能是不正确的?