You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by James Oisin Flynn <de...@hotmail.com> on 2011/01/17 16:57:30 UTC

Axis2: Difficulty/misunderstanding using axis2 asynchronous calls


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. 		 	   		  

AW: Axis2: Difficulty/misunderstanding using axis2 asynchronous calls

Posted by Stadelmann Josef <jo...@axa-winterthur.ch>.
Hi developers

 

Hi, Håkon

Thank you for the very good examples delivered in the past.

 

I struggle with axis2 services and corresponding client  BUT mainly with the setup for a true asynchron wire transport, both at client and service... 

 

This in conjunction with the JAX-WS samples provided by axis2-1.6.1

 

If the parameter as shown below is added to the service.xml then we have to deliver / deploy this setup somehow with the service

Where would you add 

<parameter name="messageReceiver.invokeOnSeparateThread">true</parameter>

BUT if no service.xml is present, as in the case of JAX-WS services, axis2 gets all this data by scanning the Hello*.jar in the WEB-INF/servicesjars directory for annotations, where and how is this parameter added? 

 

Where is it explained in the documentation?

 

As each side client and server has a Sender and a Receiver, do we need to configure the same parameter for a client side messageReceiver as well as for a server side messageReceiver?

 

Due to the symmetry we have at Client and at Server this issue is explained very confusing. I mean each side has a message sender and a message receiver and each runs in a separate thread, that makes 4 threads working, two at the client and two at the server. hence I would expect that the parameter mentioned above responsible joint with addressing engagement at client and at server, is a piece of information the client needs as well as the server.

 

AND now --- how and where do I add this parameter (and maybe others) with JAX-WS style coding of a true async-server and a true async-client?

 

any examples and thoughts welcome because the one example demonstrating ASYNC behavior, provided with axis2-1.6.1, does not run in mode "ASYNC"

 

Josef

 

 

 

Von: Håkon Sagehaug [mailto:hakon.sagehaug@uni.no] 
Gesendet: Dienstag, 18. Januar 2011 15:36
An: java-user@axis.apache.org
Betreff: Re: Axis2: Difficulty/misunderstanding using axis2 asynchronous calls

 

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 <de...@hotmail.com> 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.

 


Re: Axis2: Difficulty/misunderstanding using axis2 asynchronous calls

Posted by Håkon Sagehaug <ha...@uni.no>.
hi

You could look at this page[1]. I forgot I made it, might be something
useful

Håkon

[1] http://www.bccs.uni.no/~hakont/ws-samples/AsyncWSTutorial.html



On 21 January 2011 15:21, James Oisin Flynn <de...@hotmail.com>wrote:

>  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: hakon.sagehaug@uni.no
> To: java-user@axis.apache.org
>
>
> 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 <de...@hotmail.com>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.
>
>
>

Re: Axis2: Difficulty/misunderstanding using axis2 asynchronous calls

Posted by robert lazarski <ro...@gmail.com>.
On Mon, Jan 24, 2011 at 7:30 PM, James Oisin Flynn
<de...@hotmail.com> wrote:
> Thank you. I had seen this as an option, though it does, as you point out,
> necessitate having the client listening... That can pose a bit of a problem.
> If I can get away with that, I'll try it, otherwise I guess I'll just play
> with timeouts.

For async stuff ... I used to do it the axis2 way, but found that just
starting a thread on the service side and returning immediately works
for what I need it to do. I mean if you need a client listening
anyways, what's the point? There might be a point in some spec but
starting a thread is trivially easy. Last time I looked at the async
code generation it starts a thread anyways, IIRC.

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
For additional commands, e-mail: java-user-help@axis.apache.org


RE: Axis2: Difficulty/misunderstanding using axis2 asynchronous calls

Posted by James Oisin Flynn <de...@hotmail.com>.
Thank you. I had seen this as an option, though it does, as you point out, necessitate having the client listening... That can pose a bit of a problem. If I can get away with that, I'll try it, otherwise I guess I'll just play with timeouts.As an aside, your name rings a bell wrt JiBX? I've been using ADB as I'm using Eclipse and doing bottom up services, as things are inclined to change. I'll confess that I don't love what ADB does, but for the sake of expediency I've stuck with it so far. JiBX looks and sounds nice, so any pointers on making it play nice with Eclipse/Tomcat/Axis2 would be more than welcome.
Cheers,James.
Date: Tue, 25 Jan 2011 09:36:26 +1300
From: dms@sosnoski.com
To: java-user@axis.apache.org
Subject: Re: Axis2: Difficulty/misunderstanding using axis2 asynchronous calls






  


Hi James,



In order to get true asynchronous operation you need to use
WS-Addressing with a client listener. If nothing has changed in recent
releases this should work:



        ServiceClient client = stub._getServiceClient();

        client.engageModule("addressing");

        client.getOptions().setUseSeparateListener(true);



You need to have the addressing.mar file from the Axis2
repository/modules directory in your client classpath. I don't think
you need to add anything in the server.xml.



Hope that helps,



  - Dennis


Dennis M. Sosnoski

Java SOA and Web
Services Consulting

Axis2/CXF/Metro SOA and
Web Services Training

Web Services Jump-Start




On 01/22/2011 03:21 AM, James Oisin Flynn wrote:

  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: hakon.sagehaug@uni.no

To: java-user@axis.apache.org

  

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 <de...@hotmail.com>
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.
    
  
  
  

  
 		 	   		  

Re: Axis2: Difficulty/misunderstanding using axis2 asynchronous calls

Posted by Dennis Sosnoski <dm...@sosnoski.com>.
Hi James,

In order to get true asynchronous operation you need to use
WS-Addressing with a client listener. If nothing has changed in recent
releases this should work:

        ServiceClient client = stub._getServiceClient();
        client.engageModule("addressing");
        client.getOptions().setUseSeparateListener(true);

You need to have the addressing.mar file from the Axis2
repository/modules directory in your client classpath. I don't think you
need to add anything in the server.xml.

Hope that helps,

  - Dennis

Dennis M. Sosnoski
Java SOA and Web Services Consulting <http://www.sosnoski.com/consult.html>
Axis2/CXF/Metro SOA and Web Services Training
<http://www.sosnoski.com/training.html>
Web Services Jump-Start <http://www.sosnoski.com/jumpstart.html>


On 01/22/2011 03:21 AM, James Oisin Flynn wrote:
> 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: hakon.sagehaug@uni.no
> To: java-user@axis.apache.org
>
> 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 <den.galna.kon@hotmail.com
> <ma...@hotmail.com>> 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.
>
>

RE: Axis2: Difficulty/misunderstanding using axis2 asynchronous calls

Posted by James Oisin Flynn <de...@hotmail.com>.
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: hakon.sagehaug@uni.no
To: java-user@axis.apache.org

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 <de...@hotmail.com> 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. 		 	   		  

 		 	   		  

Re: Axis2: Difficulty/misunderstanding using axis2 asynchronous calls

Posted by Håkon Sagehaug <ha...@uni.no>.
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 <de...@hotmail.com>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.
>