关于Xfire客户端HTTP/1.1 100 Continue的解决

近,在工作中基于Xfire开发大量的WebService服务,但是始终遇到一个比较棘手的问题:

2008-6-23 10:43:44 org.apache.commons.httpclient.HttpMethodBase writeRequest
信息: 100 (continue) read timeout. Resume sending the request
2008-6-23 10:43:45 org.apache.commons.httpclient.HttpMethodBase readResponse
信息: Discarding unexpected response: HTTP/1.1 100 Continue
2008-6-23 10:43:45 org.apache.commons.httpclient.HttpMethodBase readResponse
信息: Discarding unexpected response: HTTP/1.1 100 Continue
2008-6-23 10:43:48 org.apache.commons.httpclient.HttpMethodBase writeRequest
信息: 100 (continue) read timeout. Resume sending the request
2008-6-23 10:43:48 org.apache.commons.httpclient.HttpMethodBase readResponse
信息: Discarding unexpected response: HTTP/1.1 100 Continue
2008-6-23 10:43:48 org.apache.commons.httpclient.HttpMethodBase readResponse
信息: Discarding unexpected response: HTTP/1.1 100 Continue


虽然,通过查看源代码看出这只是属于Info级别的警告。但是,频繁抛出这样的日志也还是让人不爽,通过也会影响效率。
曾以为是服务端的效率问题,可是很简单的服务情况下,没有大量并发的情况下,问题依然存在。也曾以为是网络的问题,就是部署
本地,自己调自己,还是会有这个问题。实际,上因为Xfire默认的机制下,会不断的去和服务端握手造成的。
调用下面的代码即可解决问题。

HttpClientParams params = new HttpClientParams();
// 避免'Expect: 100-continue' handshake

params.setParameter(HttpClientParams.USE_EXPECT_CONTINUE,Boolean.FALSE);
//设置ws连接超时时间
params.setParameter(HttpClientParams.CONNECTION_MANAGER_TIMEOUT, 100);
client.setProperty(CommonsHttpMessageSender.HTTP_CLIENT_PARAMS,params);
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章