Re: [axis2] asynchronous and timeout question
Hi all, I've tried to isolate the problem, and while I'm probably doing something wrong somehow, I still can't get a long running Asynchronous IN/OUT message to work based off of the user guide samples. I have done the following: 1) Downloaded .92v source. 2) Changed the userguide/example1/MyService.java to have the following Thread.sleep() : public class MyService { public OMElement echo(OMElement element) throws XMLStreamException { //Praparing the OMElement so that it can be attached to another OM Tree. //First the OMElement should be completely build in case it is not fully built and still //some of the xml is in the stream. element.build(); try { System.out.println(AXIS2 Rocks!, sleeping...); Thread.sleep(10); } catch (Exception e) { e.printStackTrace(); } //Secondly the OMElement should be detached from the current OMTree so that it can be attached //some other OM Tree. Once detached the OmTree will remove its connections to this OMElement. element.detach(); return element; } public void ping(OMElement element) throws XMLStreamException { //Do some processing } public void pingF(OMElement element) throws AxisFault{ throw new AxisFault(Fault being thrown); } } 3) Built the source with maven. 4) Installed the axis2.war . 5) Installed MyService.aar into axis2/WEB-INF/services . 6) Executed the test client testEchoNonBlockingDualClient I get the following stacktrace : Buildfile: build.xml testEchoNonBlockingDualClient: [java] org.apache.axis2.AxisFault: Read timed out; nested exception is: [java] java.net.SocketTimeoutException: Read timed out; nested exception is: [java] org.apache.axis2.AxisFault: Read timed out; nested exception is: [java] java.net.SocketTimeoutException: Read timed out; nested exception is: [java] org.apache.axis2.AxisFault: Read timed out; nested exception is: [java] java.net.SocketTimeoutException: Read timed out; nested exception is: [java] org.apache.axis2.AxisFault: Read timed out; nested exception is: [java] java.net.SocketTimeoutException: Read timed out [java] at org.apache.axis2.clientapi.InOutMEPClient.invokeNonBlocking(InOutMEPClient.java:255) [java] at org.apache.axis2.clientapi.Call.invokeNonBlocking(Call.java:136) [java] at userguide.clients.EchoNonBlockingDualClient.main(EchoNonBlockingDualClient.java:77) [java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [java] at java.lang.reflect.Method.invoke(Method.java:585) [java] at org.apache.tools.ant.taskdefs.ExecuteJava.run(ExecuteJava.java:193) [java] at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:130) [java] at org.apache.tools.ant.taskdefs.Java.run(Java.java:705) [java] at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:177) [java] at org.apache.tools.ant.taskdefs.Java.execute(Java.java:83) [java] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275) [java] at org.apache.tools.ant.Task.perform(Task.java:364) [java] at org.apache.tools.ant.Target.execute(Target.java:341) [java] at org.apache.tools.ant.Target.performTasks(Target.java:369) [java] at org.apache.tools.ant.Project.executeTarget(Project.java:1214) [java] at org.apache.tools.ant.Project.executeTargets(Project.java:1062) [java] at org.apache.tools.ant.Main.runBuild(Main.java:673) [java] at org.apache.tools.ant.Main.startAnt(Main.java:188) [java] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:196) [java] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:55) [java] Caused by: org.apache.axis2.AxisFault: Read timed out; nested exception is: [java] java.net.SocketTimeoutException: Read timed out; nested exception is: [java] org.apache.axis2.AxisFault: Read timed out; nested exception is: [java] java.net.SocketTimeoutException: Read timed out [java] at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:154) [java] at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:100) [java] at org.apache.axis2.clientapi.InOutMEPClient.invokeNonBlocking(InOutMEPClient.java:245) [java] ... 21 more [java] Caused by: org.apache.axis2.AxisFault: Read timed out; nested exception is: [java] java.net.SocketTimeoutException: Read timed out [java] at
Re: [axis2] asynchronous and timeout question
Hi Eran, thanks for the reply. I think I'm already doing everything you mentioned - my client code is basically the same as the EchoNonBlockingClient example, which I believe has useSeparateListener equal true and passes a callback into invokeNonBlocking. Of course, I'm sure I'm missing something simple. Could you please give a look at the code below? public class RCServiceClient { private static EndpointReference targetEPR = new EndpointReference(http://127.0.0.1:8080/swa/services/RCService;); public static void main(String[] args) { try { OMElement payload = ClientUtil.getEchoOMElement(); Call call = new Call(); call.setTo(targetEPR); // The boolean flag informs the axis2 engine to use two separate transport connection // to retrieve the response. call.engageModule(new QName(Constants.MODULE_ADDRESSING)); call.setTransportInfo(Constants.TRANSPORT_HTTP, Constants.TRANSPORT_HTTP, true); //Callback to handle the response Callback callback = new Callback() { public void onComplete(AsyncResult result) { try { System.out.println(inside onComplete...); StringWriter writer = new StringWriter(); result.getResponseEnvelope().serializeWithCache(XMLOutputFactory.newInstance() .createXMLStreamWriter(writer)); writer.flush(); System.out.println(writer.toString()); } catch (XMLStreamException e) { reportError(e); } } public void reportError(Exception e) { e.printStackTrace(); } }; //Non-Blocking Invocation call.invokeNonBlocking(rcExecute, payload, callback); //Wait till the callback receives the response. System.out.println(RC Service executed, sleeping until completion...); while (!callback.isComplete()) { Thread.sleep(1000); } //Need to close the Client Side Listener. call.close(); System.out.println(RC Service completed); } catch (AxisFault axisFault) { axisFault.printStackTrace(); } catch (Exception ex) { ex.printStackTrace(); } } } public class ClientUtil { public static OMElement getEchoOMElement() { OMFactory fac = OMAbstractFactory.getOMFactory(); OMNamespace omNs = fac.createOMNamespace( http://example1.org/example1;, example1); OMElement method = fac.createOMElement(rcExecute, omNs); OMElement value = fac.createOMElement(Text, omNs); value.addChild(fac.createText(value, Axis2 Echo String )); method.addChild(value); return method; } } Thanks a lot, trebor iksrazal --- Eran Chinthaka [EMAIL PROTECTED] wrote: Hi Trebor, trebor iksrazal wrote: Hi all, I've succesfully wrote a web service based off of the EchoNonBlockingClient example in the user guide. I'm using spring on the server side, if anyone needs help. Excellent, thanks for offering to help. I saw there are some people struggling to do the samething. If you have time, just explain what you did and how you did as a small tutorial and mail it here. If its good, we can put it in our Axis2 site. However, the task I execute on the web service side can take between 6 and 20 minutes. Its why I choosed axis2, so I can execute it asynchronously. Yet it gives me: java.net.SocketTimeoutException: Read timed out The reason for this is that the socket which you used to invoke server has timed out. What you can do is to use a separate listener and a pass a Callback, as Srinath has stated. You can do this by, call.setTransportInfo(Constants.TRANSPORT_HTTP, Constants.TRANSPORT_HTTP, *true*); The last argument of setTransportInfo method is whether to use the same transport for sending and receiving, or to use different transports instances for the invocation. and then call invokeNonBlocking passing a callback object for you to get the result. call.invokeNonBlocking(axisOperation, payload, callback); This is the real async invocation, which can take days to complete. My questions are: 1) Given my transport is HTTP and my long execution times, can I expect to be able to get a return value? Really I just need to know the web service completed. The answer to the question of whether you get the response back or not depends on the MEP you used. It doesn't in any means depends on the transport you used. So if your service is an INOUT one, you will
Re: [axis2] asynchronous and timeout question
Can you please send me the stacktrace too ? And are u calling a service hosted in a non-Axis2 server ? Seems so, as your target epr seems its not in an Axis2 server. But since it seems you have done the code well, its a rare chance that the epr u set it wrong. BTW, did you look at the code in EchoRawXMLOnTwoChannelsTest.testEchoXMLCompleteASync(). It has the same code as what you are trying to do. Chinthaka trebor iksrazal wrote: Hi Eran, thanks for the reply. I think I'm already doing everything you mentioned - my client code is basically the same as the EchoNonBlockingClient example, which I believe has useSeparateListener equal true and passes a callback into invokeNonBlocking. Of course, I'm sure I'm missing something simple. Could you please give a look at the code below? public class RCServiceClient { private static EndpointReference targetEPR = new EndpointReference("http://127.0.0.1:8080/swa/services/RCService"); public static void main(String[] args) { try { OMElement payload = ClientUtil.getEchoOMElement(); Call call = new Call(); call.setTo(targetEPR); // The boolean flag informs the axis2 engine to use two separate transport connection // to retrieve the response. call.engageModule(new QName(Constants.MODULE_ADDRESSING)); call.setTransportInfo(Constants.TRANSPORT_HTTP, Constants.TRANSPORT_HTTP, true); //Callback to handle the response Callback callback = new Callback() { public void onComplete(AsyncResult result) { try { System.out.println("inside onComplete..."); StringWriter writer = new StringWriter(); result.getResponseEnvelope().serializeWithCache(XMLOutputFactory.newInstance() .createXMLStreamWriter(writer)); writer.flush(); System.out.println(writer.toString()); } catch (XMLStreamException e) { reportError(e); } } public void reportError(Exception e) { e.printStackTrace(); } }; //Non-Blocking Invocation call.invokeNonBlocking("rcExecute", payload, callback); //Wait till the callback receives the response. System.out.println("RC Service executed, sleeping until completion..."); while (!callback.isComplete()) { Thread.sleep(1000); } //Need to close the Client Side Listener. call.close(); System.out.println("RC Service completed"); } catch (AxisFault axisFault) { axisFault.printStackTrace(); } catch (Exception ex) { ex.printStackTrace(); } } } public class ClientUtil { public static OMElement getEchoOMElement() { OMFactory fac = OMAbstractFactory.getOMFactory(); OMNamespace omNs = fac.createOMNamespace( "http://example1.org/example1", "example1"); OMElement method = fac.createOMElement("rcExecute", omNs); OMElement value = fac.createOMElement("Text", omNs); value.addChild(fac.createText(value, "Axis2 Echo String ")); method.addChild(value); return method; } } Thanks a lot, trebor iksrazal --- Eran Chinthaka [EMAIL PROTECTED] wrote: Hi Trebor, trebor iksrazal wrote: Hi all, I've succesfully wrote a web service based off of the EchoNonBlockingClient example in the user guide. I'm using spring on the server side, if anyone needs help. Excellent, thanks for offering to help. I saw there are some people struggling to do the samething. If you have time, just explain what you did and how you did as a small tutorial and mail it here. If its good, we can put it in our Axis2 site. However, the task I execute on the web service side can take between 6 and 20 minutes. Its why I choosed axis2, so I can execute it asynchronously. Yet it gives me: java.net.SocketTimeoutException: Read timed out The reason for this is that the socket which you used to invoke server has timed out. What you can do is to use a separate listener and a pass a Callback, as Srinath has stated. You can do this by, call.setTransportInfo(Constants.TRANSPORT_HTTP, Constants.TRANSPORT_HTTP, *true*); The last argument of setTransportInfo method is whether to use the same transport for sending and receiving, or to use different transports instances for the invocation. and then call
Re: [axis2] asynchronous and timeout question
Hi Eran, The server is Axis2 - its an existing spring/hibernate/struts app with Axis2 v.92 added in. Here's the stacktrace - I run the client via the commandline with ant: [echo] Starting rc client... [java] org.apache.axis2.AxisFault: Read timed out; nested exception is: [java] java.net.SocketTimeoutException: Read timed out; nested exception is: [java] org.apache.axis2.AxisFault: Read timed out; nested exception is: [java] java.net.SocketTimeoutException: Read timed out; nested exception is: [java] org.apache.axis2.AxisFault: Read timed out; nested exception is: [java] java.net.SocketTimeoutException: Read timed out; nested exception is: [java] org.apache.axis2.AxisFault: Read timed out; nested exception is: [java] java.net.SocketTimeoutException: Read timed out [java] at org.apache.axis2.clientapi.InOutMEPClient.invokeNonBlocking(InOutMEPClient.java:255) [java] at org.apache.axis2.clientapi.Call.invokeNonBlocking(Call.java:136) [java] at com.siemens.swa.plugins.clients.RCServiceClient.main(RCServiceClient.java:61) [java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [java] at java.lang.reflect.Method.invoke(Method.java:585) [java] at org.apache.tools.ant.taskdefs.ExecuteJava.run(ExecuteJava.java:193) [java] at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:130) [java] at org.apache.tools.ant.taskdefs.Java.run(Java.java:705) [java] at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:177) [java] at org.apache.tools.ant.taskdefs.Java.execute(Java.java:83) [java] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275) [java] at org.apache.tools.ant.Task.perform(Task.java:364) [java] at org.apache.tools.ant.Target.execute(Target.java:341) [java] at org.apache.tools.ant.Target.performTasks(Target.java:369) [java] at org.apache.tools.ant.Project.executeTarget(Project.java:1214) [java] at org.apache.tools.ant.Project.executeTargets(Project.java:1062) [java] at org.apache.tools.ant.Main.runBuild(Main.java:673) [java] at org.apache.tools.ant.Main.startAnt(Main.java:188) [java] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:196) [java] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:55) [java] Caused by: org.apache.axis2.AxisFault: Read timed out; nested exception is: [java] java.net.SocketTimeoutException: Read timed out; nested exception is: [java] org.apache.axis2.AxisFault: Read timed out; nested exception is: [java] java.net.SocketTimeoutException: Read timed out [java] at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:154) [java] at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:100) [java] at org.apache.axis2.clientapi.InOutMEPClient.invokeNonBlocking(InOutMEPClient.java:245) [java] ... 21 more [java] Caused by: org.apache.axis2.AxisFault: Read timed out; nested exception is: [java] java.net.SocketTimeoutException: Read timed out [java] at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:204) [java] at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:123) [java] ... 23 more [java] Caused by: java.net.SocketTimeoutException: Read timed out [java] at java.net.SocketInputStream.socketRead0(Native Method) [java] at java.net.SocketInputStream.read(SocketInputStream.java:129) [java] at java.io.BufferedInputStream.fill(BufferedInputStream.java:218) [java] at java.io.BufferedInputStream.read(BufferedInputStream.java:235) [java] at org.apache.commons.httpclient.HttpParser.readRawLine(HttpParser.java:77) [java] at org.apache.commons.httpclient.HttpParser.readLine(HttpParser.java:105) [java] at org.apache.commons.httpclient.HttpConnection.readLine(HttpConnection.java:1110) [java] at org.apache.commons.httpclient.HttpMethodBase.readStatusLine(HttpMethodBase.java:1832) [java] at org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBase.java:1592) [java] at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:995) [java] at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:393) [java] at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:168) [java] at
Re: [axis2] asynchronous and timeout question
Hi Eran, The web service works fine if I have only a short task.I'm logging a success message in the web service so I know for sure. It gives me a timeout error when I try to execute my long task, but I still get a logged message saying it did get there and it does start executing my long task. The 'swa' reference is for our existing app. I put the needed servlet mappings in our web.xml, as well as axis2.xml in our WEB-INF, etc. Can I do that, ie, could this be my problem? It'd be too dificult to try and put our app in the axis2 war, but I suppose I could try putting my web service there, and putting a Thread.sleep there instead of our app. In the end, we need to continue using our current erp with swa - its a big existing app. Worth a shot, cheers, iksrazal --- Eran Chinthaka [EMAIL PROTECTED] wrote: your epr was http://127.0.0.1:8080/swa/services/RCService; In Axis2 the EPR should contain protocol://ip:port/axis2/services/serviceName but I can see your EPR contains swa, without axis2. Did you change the mapping in Struts ? Or can this be the problem. Change it to axis2 and check. trebor iksrazal wrote: Hi Eran, The server is Axis2 - its an existing spring/hibernate/struts app with Axis2 v.92 added in. Here's the stacktrace - I run the client via the commandline with ant: [echo] Starting rc client... [java] org.apache.axis2.AxisFault: Read timed out; nested exception is: [java] java.net.SocketTimeoutException: Read timed out; nested exception is: [java] org.apache.axis2.AxisFault: Read timed out; nested exception is: [java] java.net.SocketTimeoutException: Read timed out; nested exception is: [java] org.apache.axis2.AxisFault: Read timed out; nested exception is: [java] java.net.SocketTimeoutException: Read timed out; nested exception is: [java] org.apache.axis2.AxisFault: Read timed out; nested exception is: [java] java.net.SocketTimeoutException: Read timed out [java] at org.apache.axis2.clientapi.InOutMEPClient.invokeNonBlocking(InOutMEPClient.java:255) [java] at org.apache.axis2.clientapi.Call.invokeNonBlocking(Call.java:136) [java] at com.siemens.swa.plugins.clients.RCServiceClient.main(RCServiceClient.java:61) [java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [java] at java.lang.reflect.Method.invoke(Method.java:585) [java] at org.apache.tools.ant.taskdefs.ExecuteJava.run(ExecuteJava.java:193) [java] at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:130) [java] at org.apache.tools.ant.taskdefs.Java.run(Java.java:705) [java] at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:177) [java] at org.apache.tools.ant.taskdefs.Java.execute(Java.java:83) [java] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275) [java] at org.apache.tools.ant.Task.perform(Task.java:364) [java] at org.apache.tools.ant.Target.execute(Target.java:341) [java] at org.apache.tools.ant.Target.performTasks(Target.java:369) [java] at org.apache.tools.ant.Project.executeTarget(Project.java:1214) [java] at org.apache.tools.ant.Project.executeTargets(Project.java:1062) [java] at org.apache.tools.ant.Main.runBuild(Main.java:673) [java] at org.apache.tools.ant.Main.startAnt(Main.java:188) [java] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:196) [java] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:55) [java] Caused by: org.apache.axis2.AxisFault: Read timed out; nested exception is: [java] java.net.SocketTimeoutException: Read timed out; nested exception is: [java] org.apache.axis2.AxisFault: Read timed out; nested exception is: [java] java.net.SocketTimeoutException: Read timed out [java] at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:154) [java] at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:100) [java] at org.apache.axis2.clientapi.InOutMEPClient.invokeNonBlocking(InOutMEPClient.java:245) [java] ... 21 more [java] Caused by: org.apache.axis2.AxisFault: Read timed out; nested exception is: [java] java.net.SocketTimeoutException: Read timed out [java] at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:204) [java] at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:123) [java]
[axis2] asynchronous and timeout question
Hi all, I've succesfully wrote a web service based off of the EchoNonBlockingClient example in the user guide. I'm using spring on the server side, if anyone needs help. However, the task I execute on the web service side can take between 6 and 20 minutes. Its why I choosed axis2, so I can execute it asynchronously. Yet it gives me: java.net.SocketTimeoutException: Read timed out My questions are: 1) Given my transport is HTTP and my long execution times, can I expect to be able to get a return value? Really I just need to know the web service completed. 2) Is my only option InOnly, ie 'fire and forget' ? iksrazal None are more hopelessly enslaved than those who falsely believe they are free. -- Goethe __ Yahoo! FareChase: Search multiple travel sites in one click. http://farechase.yahoo.com
Re: [axis2] asynchronous and timeout question
you can set the option useSeparateListener to true in the call and pass a callback using invokeNonBlocking() , and then the response will be send in a seperate transport connection to a listener started at te client side. In this case there could be days ;) between the response and the request Thanks Srinath On 10/31/05, trebor iksrazal [EMAIL PROTECTED] wrote: Hi all, I've succesfully wrote a web service based off of the EchoNonBlockingClient example in the user guide. I'm using spring on the server side, if anyone needs help. However, the task I execute on the web service side can take between 6 and 20 minutes. Its why I choosed axis2, so I can execute it asynchronously. Yet it gives me: java.net.SocketTimeoutException: Read timed out My questions are: 1) Given my transport is HTTP and my long execution times, can I expect to be able to get a return value? Really I just need to know the web service completed. 2) Is my only option InOnly, ie 'fire and forget' ? iksrazal None are more hopelessly enslaved than those who falsely believe they are free. -- Goethe __ Yahoo! FareChase: Search multiple travel sites in one click. http://farechase.yahoo.com