最近项目中使用axis2 1.5.3 遇到如下错误:
org.apache.axis2.AxisFault: Timeout waiting for connection
at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)
at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:203*/
表现:每次测试超过3次,就会提示超时;
在网上搜索得到如下答案:
来源:(http://blog.sina.com.cn/s/blog_5052ef9d0100hom6.html) - org.apache.axis2.AxisFault: Timeout waiting for co_IT_刘政_IT_新浪博客
解决方案:
Java客户端注意:每次调用完之后,
RPCServiceClient的对象serviceClient执行serviceClient.cleanupTransport();
C#客户端注意:sender参数执行sender.cleanupTransport();
来源:(http://blog.sina.com.cn/s/blog_5052ef9d0100hom6.html) - org.apache.axis2.AxisFault: Timeout waiting for co_IT_刘政_IT_新浪博客
但在iteye博客: http://xubaolin9.iteye.com/blog/701414上说使用上述解决方案,还是没有解决。
继续Google搜索,发现这篇文章
https://issues.apache.org/jira/browse/AXIS2-4752
他从AXIS2 1.5升级到1.5.2出现了这样的问题,解决该问题的补丁如下:
From c63f24b3903a01d8357269a402ef611af4923188 Mon Sep 17 00:00:00 2001
From: Shawn Jiang <[email protected]>
Date: Fri, 25 Jun 2010 16:46:04 +0800
Subject: [PATCH] cleanup the connection after each CALL in SOAPConnectionImpl.
---
.../org/apache/axis2/saaj/SOAPConnectionImpl.java | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/modules/saaj/src/org/apache/axis2/saaj/SOAPConnectionImpl.java b/modules/saaj/src/org/apache/axis2/saaj/SOAPConnectionImpl.java
index bee53b3..718485d 100644
--- a/modules/saaj/src/org/apache/axis2/saaj/SOAPConnectionImpl.java
+++ b/modules/saaj/src/org/apache/axis2/saaj/SOAPConnectionImpl.java
@@ -192,6 +192,13 @@ public class SOAPConnectionImpl extends SOAPConnection {
return getSOAPMessage(msgCtx.getEnvelope());
} catch (Exception e) {
throw new SOAPException(e.getMessage(), e);
+ } finally {
+
+ try {
+ requestMsgCtx.getTransportOut().getSender().cleanup(requestMsgCtx);
+ } catch (Exception e) {
+ // ignore the error, better to log somewhere if possible.
+ }
}
}
--
1.7.0.2.msysgit.0
我的解决办法是降级到1.5,问题解决。