关于axis1.4中提高传输性能的分析

http://hi.baidu.com/%B1%A9%D7%DFboy/blog/item/dbaf25dd572bd8e439012fd5.html


1. 使用http1.1。 默认情况下,axis1.4使用的transport handler是HttpSender,这个类默认使用http1.0作为它的传输标准。而http1.0是不提供persistent connection(keep-alive)模式的,这样每次call都会建立一次新的连接,尤其是对于ssl的连接来说,这个开销就有点霸道了。http11的标准提供了keep-alive机制,把axis的transport升级成http11能节约不必要的连接建立开销。具体做法有:

(1)调用client call(org.apache.axis.client.Call)来setProperty(MessageContext.HTTP_TRANSPORT_VERSION, HTTPConstants.HEADER_PROTOCOL_11);

(2)把transport handler改成Jakarta的CommonsHTTPSender。这个需要设置axis engine使其来使用CommonsHTTPSender,在初始化axis.client.Service之前set engine configuration(因为在初始化Service的时候axis回去加载engine configuration)。AxisProperties.setProperty(EngineConfigurationFactory.SYSTEM_PROPERTY_NAME, "com.test.CustomerEngineConfiguraiontFactory"),这样写的目的是告诉axis去使用我们自己定义的factory。 这个CustomerEngineConfiguraiontFactory实现了axis的EngineConfigurationFactory接口,在这个接口实现类里面set了engine configuration。一个简单的实现如下:

public EngineConfiguration getClientEngineConfig() {
SimpleProvider engineProvider = new SimpleProvider ();
engineProvider.deployTransport(HTTPTransport.DEFAULT_TRANSPORT_NAME
, new CommonsHTTPSender());
return engineProvider;
}

2. 压缩传输数据。 这个需要在设置了transport为http11后才能使用。用axis.client.Call去set相应的property:

call.setProperty(HTTPConstants.MC_GZIP_REQUEST, Boolean.TRUE);
call.setProperty(HTTPConstants.MC_ACCEPT_GZIP, Boolean.TRUE);

可以参考这里,http://www.pocketsoap.com/weblog/2005/10/1565.html

--end
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值