android post gzip

Ker*_*ern 6 wcf android gzip

尝试在Android项目上实现gzip以减少客户端数据费用.所有设备都连接到WCF Web服务,IIS现在正按预期将压缩数据发送回设备.现在我需要弄清楚如何回发在Android设备上修改的gzip压缩xml数据.设备代码如下

     httpsURLConnection.setDoInput(true);
     httpsURLConnection.setDoOutput(true);
     httpsURLConnection.setConnectTimeout(TIMEOUT);
     httpsURLConnection.setReadTimeout(TIMEOUT);
     httpsURLConnection.setRequestMethod("POST");
     httpsURLConnection.setRequestProperty("Content-Type", "application/xml");
     httpsURLConnection.setRequestProperty("Content-Encoding", "gzip);
     httpsURLConnection.connect();

     GZIPOutputStream gzipOutputStream = new GZIPOutputStream(new BufferedOutputStream((httpsURLConnection.getOutputStream())));
     gzipOutputStream.write(_xmlText.getBytes());
     gzipOutputStream.flush();
     gzipOutputStream.finish();
     gzipOutputStream.close();
Run Code Online (Sandbox Code Playgroud)

在Web服务器上运行Wireshark会显示gzip数据包并对其进行解压缩以显示设备中的正确数据.问题是WCF Web服务似乎无法识别数据 - 错误是XmlException - 根级别的数据无效.第1行,第1位.这让我觉得数据仍然被压缩,WCF无法处理gzip - 我似乎记得以前读过的.那么我是否需要在.net中创建一个消息解码器来处理gzip压缩?希望在.net 4.5中解决这个问题吗?

对这些问题的任何帮助表示赞赏