axis2调用WebService出现Timeout waiting for connection
2016-08-22 11:32
435 查看
最近在项目中遇到使用Axis2版本1.5.4调用Webservice不定期的出现Timeout waiting for connection的问题,但是我自己调试的时候一直无法重现问题(调试版本1.6.2),纠结半天,感觉像是版本不同而引起的,于是查了一下文档,发现真是版本的问题。调用代码如下:
异常信息如下:
解决方案:
1、使用高版本的axis2,我使用版本1.6.2是没有问题的,查看了一下Apache的官方文档说这个是版本1.5.1之后的一个BUG,至于在哪个版本修复了没明确说明,具体参考:https://issues.apache.org/jira/browse/AXIS2-4797
2、修改调用代码,增加三行加粗的代码,如下:
感谢博主的分享:http://blog.csdn.net/liufeng520/article/details/8464211
RPCServiceClient serviceClient = new RPCServiceClient(); Options options = serviceClient.getOptions(); String transport = "http://10.50.81.49"; // 指定调用WebService的URL EndpointReference targetEPR = new EndpointReference(transport + "/back_sms/interfaces/smsInterface?wsdl"); options.setAction("sendSms"); options.setTo(targetEPR); String smsContent = "255555522222222222266522222222222"; Object[] opAddEntryArgs = new Object[] { "gms","gms#2016","13910565512",smsContent }; @SuppressWarnings("rawtypes") Class[] classes = new Class[] { String.class }; QName opAddEntry = new QName("http://webservice.sms.foresealife.com/","sendSms"); String result = serviceClient.invokeBlocking(opAddEntry, opAddEntryArgs, classes)[0].toString(); System.out.println("调用短信平台结果=="+result);
异常信息如下:
2016-08-05 10:11:05,922 INFO [org.apache.axis2.transport.http.HTTPSender] (Timer-5) Unable to sendViaPost to url[http://<span style="font-family: Arial, Helvetica, sans-serif;">10.50.81.49</span><span style="font-family: Arial, Helvetica, sans-serif;">/back_sms/interfaces/smsInterface]</span> org.apache.commons.httpclient.ConnectionPoolTimeoutException: Timeout waiting for connection at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager.doGetConnection(MultiThreadedHttpConnectionManager.java:490) at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager.getConnectionWithTimeout(MultiThreadedHttpConnectionManager.java:394) at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:152) at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:396) at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:346) at org.apache.axis2.transport.http.AbstractHTTPSender.executeMethod(AbstractHTTPSender.java:557) at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:199) at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:76) at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:400) at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:225) at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:438) at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:402) at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229) at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165) at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:540) at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:521) at org.apache.axis2.rpc.client.RPCServiceClient.invokeBlocking(RPCServiceClient.java:102) at com.foresealife.sms.webservice.SmsAxis2Client.sendSms(SmsAxis2Client.java:51) at com.sinosoft.smsInterface.SmsServicePub.sendMessage(SmsServicePub.java:34) at com.sinosoft.utility.SMSNewCallDataTimerTask.run(SMSNewCallDataTimerTask.java:79) at java.util.TimerThread.mainLoop(Timer.java:512) at java.util.TimerThread.run(Timer.java:462) 2016-08-05 10:11:05,923 INFO [STDOUT] (Timer-5) 调用短信平台(ESB)异常
解决方案:
1、使用高版本的axis2,我使用版本1.6.2是没有问题的,查看了一下Apache的官方文档说这个是版本1.5.1之后的一个BUG,至于在哪个版本修复了没明确说明,具体参考:https://issues.apache.org/jira/browse/AXIS2-4797
2、修改调用代码,增加三行加粗的代码,如下:
RPCServiceClient serviceClient = new RPCServiceClient(); Options options = serviceClient.getOptions(); String transport = "http://10.50.81.49"; // 指定调用WebService的URL EndpointReference targetEPR = new EndpointReference(transport + "/back_sms/interfaces/smsInterface?wsdl"); options.setAction("sendSms"); options.setTo(targetEPR); options.setManageSession(true); options.setProperty(HTTPConstants.REUSE_HTTP_CLIENT,true); String smsContent = "255555522222222222266522222222222"; Object[] opAddEntryArgs = new Object[] { "gms","gms#2016","13910565512",smsContent }; @SuppressWarnings("rawtypes") Class[] classes = new Class[] { String.class }; QName opAddEntry = new QName("http://webservice.sms.foresealife.com/","sendSms"); String result = serviceClient.invokeBlocking(opAddEntry, opAddEntryArgs, classes)[0].toString(); serviceClient.cleanupTransport(); System.out.println("调用短信平台结果=="+result);
感谢博主的分享:http://blog.csdn.net/liufeng520/article/details/8464211
相关文章推荐
- HttpClient连接池出现连续ConnectionPoolTimeoutException:Timeout waiting for connection from pool异常
- Axis2 - Timeout waiting for connection 问题解决方法
- AxisFault: Timeout waiting for connection
- Cannot get a connection, pool error Timeout waiting for idle object
- 如何解决Cannot get a connection, pool error Timeout waiting for idle object
- Cannot get a connection, pool error Timeout waiting for idle object
- org.apache.commons.httpclient.ConnectionPoolTimeoutException: Timeout waiting for connection异常解决方案
- AXIS调用jws发布的webservice出现Cannot find dispatch method for
- AXIS调用jws发布的webservice出现Cannot find dispatch method for
- HttpClient连接池抛出大量ConnectionPoolTimeoutException: Timeout waiting for connection
- ArcGIS API for Silverlight 调用WebService出现跨域访问报错的解决方法
- ConnectionPoolTimeoutException: Timeout waiting for connection
- ConnectionPoolTimeoutException: Timeout waiting for connection
- ArcGIS API for Silverlight 调用WebService出现跨域访问报错的解决方法
- org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot get a connection, pool error Timeout waiting for idle object异常原因
- AXIS调用jws发布的webservice出现Cannot find dispatch method for
- HttpClient ConnectionPoolTimeoutException: Timeout waiting for connection
- 用Java axis2调用.net平台的Webservice出现的一些问题
- sql异常:nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot get a connection, pool error Timeout waiting for idle object
- HttpClient连接池抛出大量ConnectionPoolTimeoutException: Timeout waiting for connection异常排查