axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ashish Soni <ashishson...@gmail.com>
Subject [Axis2] how to close client when using setUseSeparateListener with Non-Blocking Invocation
Date Tue, 28 Apr 2015 13:56:12 GMT
Hi,



I am trying to implement the example mentioned in Apache Axis2 Advanced
User’s Guide [http://axis.apache.org/axis2/java/core/docs/adv-userguide.html].




When writing the web service client using “Do a Non-Blocking Invocation” I
found that:

1)       it’s not terminating the client

2)      Next execution of client it’s not calling the
Axis2SampleDocLitServiceCallbackHandler

3)      both client hang.

4)      All for further execution of client hang without entering to
Axis2SampleDocLitServiceCallbackHandler.



I found that it’s happening because it use a separate Listener for response
and after first execution of client it’s not getting cleaned up, so further
call to client hang and not entering to
Axis2SampleDocLitServiceCallbackHandler.



Code Snippet:



package org.apache.axis2.userguide;



import java.rmi.RemoteException;



import org.apache.axis2.AxisFault;

import org.apache.axis2.Constants;

import org.apache.axis2.transport.http.HTTPConstants;

import org.apache.axis2.userguide.xsd.EchoStringParamDocument;

import org.apache.axis2.userguide.xsd.EchoStringReturnDocument;



public class Axis2SampleDocLitServiceClient {

                public static void main(String[] args) {

                                Axis2SampleDocLitServiceStub stub= null;

                                try{

                                                stub= new
Axis2SampleDocLitServiceStub("
http://localhost:9090/axis2/services/Axis2SampleDocLitService");



                                                EchoStringParamDocument
reqDoc= EchoStringParamDocument.Factory.newInstance();


reqDoc.setEchoStringParam("Ashish Soni");



/**

                                                 * Do a Non-Blocking
Invocation

                                                 */


*stub._getServiceClient().engageModule("addressing");*

*
stub._getServiceClient().getOptions().setUseSeparateListener(true);*

*
stub._getServiceClient().getOptions().setProperty(HTTPConstants.AUTO_RELEASE_CONNECTION,
Constants.VALUE_TRUE);*

*
stub._getServiceClient().getOptions().setProperty(HTTPConstants.REUSE_HTTP_CLIENT,
Constants.VALUE_FALSE);*




Axis2SampleDocLitServiceCallbackHandler handler= new
Axis2SampleDocLitServiceCallbackHandler()
{


                                                                @Override

                                                                public void
receiveErrorechoString(Exception e) {


System.out.println(e.getMessage());

                                                                }



                                                                @Override

                                                                public void
receiveResultechoString(


EchoStringReturnDocument result) {


System.out.println("Callback Handler called: " +
result.getEchoStringReturn());


completed= true;

                                                                }

                                                };




stub.startechoString(reqDoc, handler);





stub._getServiceClient().getOptions().getTransportIn().getReceiver().destroy();

                                }catch(RemoteException fault) {

                                                fault.printStackTrace();

                                } finally {

                                                if(stub!=null) {

                                                                try{


*stub._getServiceClient().cleanupTransport();
*


}catch(AxisFault fault) {


// Nothing need to be done

                                                                }

                                                }

                                }

                }

}



Could please help how to do the clean of *“response stream” *after getting
the reponse.



References followed:

http://axis.apache.org/axis2/java/core/docs/adv-userguide.html

http://amilachinthaka.blogspot.in/2010/01/improving-axis2-http-transport-client.html




-- 
Ashish Soni
Bangalore(Karnataka)- 560076

"A dream becomes a goal when action is taken toward its achievement."

Mime
View raw message