axis2:ServiceClient增加GZIP压缩支持
来源:互联网 发布:polycom软件下载 编辑:程序博客网 时间:2024/06/03 22:56
使用axis2的ServiceClient,以RPC或Stub方式实现webservice调用时,如果要对数据进行GZIP压缩,也挺简单,只要给ServiceClient设置 MC_GZIP_REQUEST和MC_ACCEPT_GZIP 属性就可以了。
示例代码如下:
Options options = serviceClient.getOptions(); options.setProperty(HTTPConstants.CACHED_HTTP_CLIENT, httpClient); options.setProperty(HTTPConstants.REUSE_HTTP_CLIENT, "true"); options.setProperty(HTTPConstants.CHUNKED, "true"); // Request(请求)数据用GZIP压缩 options.setProperty(HTTPConstants.MC_GZIP_REQUEST, Boolean.TRUE); // 向服务器声明接受GZIP压缩 options.setProperty(HTTPConstants.MC_ACCEPT_GZIP , Boolean.TRUE);
关于MC_GZIP_REQUEST和MC_ACCEPT_GZIP 属性的说明参见org.apache.axis2.transport.http.HTTPConstants代码中的注释:
/** * If you want the HTTP sender to indicate that it can accept a gziped * response, set this message context property to true. The sender will * automatically unzip the response if its gzipped. */ public static final String MC_ACCEPT_GZIP = "transport.http.acceptGzip"; /** * by default the HTTP request body is not compressed. set this message * context property to true to have the request body gzip compressed. */ public static final String MC_GZIP_REQUEST = "transport.http.gzipRequest";
以及方法void org.apache.axis2.client.Options.setProperty(String propertyKey, Object property)的说明:
org.apache.axis2.transport.http.HTTPConstants.MC_GZIP_REQUESTIf set this will GZip your request and send over to the destination. Before doing this, you must make sure that the receiving end supports GZip compressed streams. Possible values are:"true"/"false" or Boolean.TRUE/Boolean.FALSEorg.apache.axis2.transport.http.HTTPConstants.MC_ACCEPT_GZIPWhether or not you send a gzip-ped request, you can choose to receive GZIP back from the server using this flag.Possible values are:"true"/"false" or Boolean.TRUE/Boolean.FALSE
0 0
- axis2:ServiceClient增加GZIP压缩支持
- 让apache支持gzip压缩
- Java压缩Zlib,Gzip,Zip支持J2ME
- Rails 支持 Response 数据 GZip 压缩 json
- gzip工具类 支持字符串压缩解压缩
- gzip压缩
- GZip压缩
- GZIP压缩
- Gzip压缩
- GZIP压缩
- Gzip压缩
- GZIP压缩
- GZIP --压缩
- Gzip压缩
- GZIP压缩
- Gzip压缩
- gzip压缩
- gzip压缩
- RxJava 合并组合两个(或多个)Observable数据源
- RxJava的懒加载,慎重使用自定义操作符,优先考虑内置操作符
- 在线Cron表达式生成器
- 网络协议简介
- RxJava 错误处理
- axis2:ServiceClient增加GZIP压缩支持
- 【模拟一】笨笨玩游戏
- 第二周 项目3(2) - 体验复杂度-汉诺塔程序
- hdu 3718 Similarity【KM匹配】
- 近期遇到的Android问题解决与总结
- spark Streaming 实例
- Linux安装android开发环境
- 分析函数——FIRST_VALUE()和LAST_VALUE()
- HDOJ 5744 Keep On Movin