Hello!
I have a sample axis2 client where everything i do is invoking a web
service, the problem is that the third time i invoke such webservice it
always throws a timeout exception. I guess this has to do with some
connection limit or something but after checking axis2.xml i was not able to
find out how to solve the issue.
I guess there is a way to tell the axis2 server to keep alive the connection
or close it after its been used. I am no expert here, but it looks like a
connection pooling issue to me.
Thanks in advance!
Here is the code:
public class Axis2Client {
/**
* @param args
*/
public static void main(String[] args) {
Object[] datosUsuario;
String user = "user";
String pass = "pass";
try{
//first invocation
datosUsuario = invokeWebService("
http://localhost:8180/axis2/services/LoginService", "login", new Object[]
{user, pass},new Class[] { Long.class, String.class, String.class,
String.class});
for(int i = 0; i < datosUsuario.length; i++)
System.out.println(i + " -> " + datosUsuario[i]);
//second invocation
datosUsuario = invokeWebService("
http://localhost:8180/axis2/services/LoginService", "login", new Object[]
{user, pass},new Class[] { Long.class, String.class, String.class,
String.class});
for(int i = 0; i < datosUsuario.length; i++)
System.out.println(i + " -> " + datosUsuario[i]);
//third invocation
datosUsuario = invokeWebService("
http://localhost:8180/axis2/services/LoginService", "login", new Object[]
{user, pass},new Class[] { Long.class, String.class, String.class,
String.class});
for(int i = 0; i < datosUsuario.length; i++)
System.out.println(i + " -> " + datosUsuario[i]);
}
catch(Exception e){
e.printStackTrace();
}
}
public static Object[] invokeWebService(String endPoint, String op,
Object[] opArgs, Class[] returnTypes) throws AxisFault{
RPCServiceClient serviceClient;
Options options;
EndpointReference targetEPR;
QName opQName;
Object[] response = new Object[]{};
//inicializo el cliente
serviceClient = new RPCServiceClient();
options = serviceClient.getOptions();
//establezcp el endpoint
targetEPR = new EndpointReference(endPoint);
options.setTo(targetEPR);
//establezco la operacion
opQName = new QName("
http://services.spring.webservices.dietaclub.akyasociados.com.ar", op);
//invoco el web service utilizando los parametros y los tipos que
espero que me sean devueltos
try{
response = serviceClient.invokeBlocking(opQName, opArgs,
returnTypes);
}
catch(AxisFault e){
e.printStackTrace();
throw e;
}
catch(Exception e){
e.printStackTrace();
}
return response;
}
}
Here is the exception:
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)
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:435)
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 Axis2Client.invokeWebService(Axis2Client.java:88)
at Axis2Client.main(Axis2Client.java:54)
Caused by: org.apache.commons.httpclient.ConnectionPoolTimeoutException:
Timeout waiting for connection
at
org.apache.commons.httpclient.MultiThreadedHttpConnectionManager.doGetConnection(MultiThreadedHttpConnectionManager.java:497)
at
org.apache.commons.httpclient.MultiThreadedHttpConnectionManager.getConnectionWithTimeout(MultiThreadedHttpConnectionManager.java:416)
at
org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:153)
at
org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
at
org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:346)
at
org.apache.axis2.transport.http.AbstractHTTPSender.executeMethod(AbstractHTTPSender.java:542)
at
org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:199)
... 12 more
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)
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:435)
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 Axis2Client.invokeWebService(Axis2Client.java:88)
at Axis2Client.main(Axis2Client.java:54)
Caused by: org.apache.commons.httpclient.ConnectionPoolTimeoutException:
Timeout waiting for connection
at
org.apache.commons.httpclient.MultiThreadedHttpConnectionManager.doGetConnection(MultiThreadedHttpConnectionManager.java:497)
at
org.apache.commons.httpclient.MultiThreadedHttpConnectionManager.getConnectionWithTimeout(MultiThreadedHttpConnectionManager.java:416)
at
org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:153)
at
org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
at
org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:346)
at
org.apache.axis2.transport.http.AbstractHTTPSender.executeMethod(AbstractHTTPSender.java:542)
at
org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:199)
... 12 more