//创建请求msg后,设置header MimeHeaders headers = soapMsg.getMimeHeaders(); heders.addHeader("Accept-Encoding", "gzip,deflate");
//调用 SOAPMessage response = conn.call(soapMsg, url);
//解压数据 ByteArrayOutputStream out = new ByteArrayOutputStream(); response.writeTo(out); byte[] barr = out.toByteArray(); InputStream gzipStream = new GZIPInputStream(new ByteArrayInputStream(barr)); Reader decoder = new InputStreamReader(gzipStream, "UTF-8"); BufferedReader buffered = new BufferedReader(decoder); int n = 0; char[] cbuf = new char[1024]; Writer w = new StringWriter(); while ((n = buffered.read(cbuf)) != -1) { w.write(cbuf,0,n); } //得到字符串 System.out.println(w.toString());
|