On further investigation, it appears to me that the asynchronous interface on 
the client side is in actual fact no different from the synchronous interface, 
other than the nicety of allowing the client to get on with doing something 
else while its request is brewing. I had rather assumed that the asynchronous 
client would somehow politely play byte ping pong with the server side to keep 
the connection from timing out whilst the call was executing. Is this the case? 
If so, does this simply imply that in order to allow for an arbitrarily long 
call, it is only a matter of increasing to timeout?
Regards,James.

Date: Tue, 18 Jan 2011 15:35:42 +0100
Subject: Re: Axis2: Difficulty/misunderstanding using axis2 asynchronous calls
From: [email protected]
To: [email protected]

hi

I had to add this line 
 <parameter name="messageReceiver.invokeOnSeparateThread">true</parameter>


In my services.xml, have you tried that? 

Håkon


On 17 January 2011 16:57, James Oisin Flynn <[email protected]> wrote:







I am having difficulties getting an asynchronous axis2 client to work, very 
possibly due to my misunderstanding of the way axis2 is supposed to work, 
though I have not been able to find any analogous examples.


I have a web service created in Eclipse using the bottom up approach. The web 
service in question works fine synchronously, but really needs to function 
asynchronously due to unpredictable latencies. The interface and 
implementations of a part of this web service are the following

Interface:

@WebService@SOAPBinding( style = Style.DOCUMENT )public interface 
DatabaseSource{       @WebMethod      @WebResult( name = "TableColumns", 
targetNamespace = "http://rec.ws"; )
        public TableColumn[] reflectTable(                      @WebParam( name 
= "SessionId", targetNamespace = "http://rec.ws"; )
                        SessionId sessionId,                    @WebParam( name 
= "DatabaseConfig", targetNamespace = "http://rec.ws"; )
                        String sourceName,                      @WebParam( name 
= "Table", targetNamespace = "http://rec.ws"; )
                        String tableName ) throws SQLException, 
ReconciliationException;}

Implementation:
public class DatabaseSourceWS implements DatabaseSource
{       private ReconciliationServices reconciliationServer;
                public DatabaseSourceWS()
        {               if ( reconciliationServer == null )
                {                       reconciliationServer = 
ReconciliationServiceWS.getService();
                }       }

        public TableColumn[]
        reflectTable( SessionId sessionId, String sourceName, String tableName )
        throws SQLException, ReconciliationException
        {               ReconciliationServiceImpl service =
                        reconciliationServer.getSession( sessionId );
                database.isl.DatabaseSource source =
                        service.getSource( sourceName );
                Table table = service.getTable( tableName );
                if ( source != null && table != null )
                {                       source.connect();
                        source.reflectTable( table );
                        return table.getColumns();
                }               return null;
        }}


The client is also built using Eclipse and Axis2 from the WSDL generated when 
the service is generated.
The client, and it's callback handler are the following...

The callback handler:
        private class SourceCallbackHandler extends 
DatabaseSourceWSCallbackHandler
        implements Runnable
        {               private SourceCallbackHandler()
                {                       Thread waitThread = new Thread( this );
                        waitThread.start();
                }

                public void run()
                {                       synchronized ( this )
                        {                               try
                                {                                       
this.wait();
                                }                               catch ( 
InterruptedException cont )
                                {}                      }
                }

                private void continu()
                {                       synchronized ( this )
                        {                               this.notifyAll();
                        }               }

                private TableColumn[] columns;
                public void receiveResultreflectTable( ReflectTableResponse 
result )
                {                       columns = result.get_return();
                        continu();
                }

                public void receiveErrorreflectTable( java.lang.Exception e )
                {                       e.printStackTrace();
                        // throw a new exception and run continu() in finally 
clause.
                        continu();
                }

                public TableColumn[] getColumns()
                { return columns; }
        }


The client:
        public DatabaseSourceClient()
        {               try
                {                       this.databaseSourceStub = new 
DatabaseSourceWSStub();
                }               catch ( AxisFault af )
                {                       af.printStackTrace();
                }       }

        public void setSessionId( SessionId sessionId )
        {               this.sessionId = sessionId;
        }

        public void setSourceConfig( DatabaseConfig sourceConfig )
        {               this.sourceConfig = sourceConfig;
        }

       // ....  
        public void reflectTable( Table table ) throws SQLException
        {               ReflectTable reflect = new ReflectTable();
                reflect.setSessionId( buildSession());
                reflect.setSourceName( sourceConfig.getSourceName());
                reflect.setTableName( table.getName());
                SourceCallbackHandler handler = new SourceCallbackHandler();
                try             {
                        synchronized ( handler )
                        {                               
databaseSourceStub.startreflectTable( reflect, handler );
                                handler.wait();
                        }               }
                catch ( RemoteException re )
                {                       re.printStackTrace();
                }               catch ( InterruptedException cont ){}
                if ( handler.getColumns() != null )
                {                       setColumns( table, 
handler.getColumns());
                }       }
}


On execution, with the following code. The client successfully connects to the 
web service. The web service successfully completes, and directly returns the 
result of the operation, an array of columns, to the client. However, the reply 
is somehow not received. The client sits in wait until the socket times out, 
and then exits through the callback handlers receiveErrorreflectTable( 
java.lang.Exception e ) method with the following exception:

org.apache.axis2.AxisFault: Read timed out      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$NonBlockingInvocationWorker.run(OutInAxisOperation.java:442)
        at 
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:619)
Caused by: java.net.SocketTimeoutException: Read timed out      at 
java.net.SocketInputStream.socketRead0(Native Method)
        at java.net.SocketInputStream.read(SocketInputStream.java:129)
        at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
        at java.io.BufferedInputStream.read(BufferedInputStream.java:237)
        at 
org.apache.commons.httpclient.HttpParser.readRawLine(HttpParser.java:78)
        at 
org.apache.commons.httpclient.HttpParser.readLine(HttpParser.java:106)
        at 
org.apache.commons.httpclient.HttpConnection.readLine(HttpConnection.java:1116)
        at 
org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.readLine(MultiThreadedHttpConnectionManager.java:1413)
        at 
org.apache.commons.httpclient.HttpMethodBase.readStatusLine(HttpMethodBase.java:1973)
        at 
org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBase.java:1735)
        at 
org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1098)
        at 
org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:398)
        at 
org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
        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)
...
Any help or suggestions would be welcome.
Cheers.                                           

                                          

Reply via email to