關於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);
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章