//client classes declared static obviates multi-threaded activity on client side
//options.setuseSeparateListener(true) will apprise the engine to use 2
separate channels
//one for send and one for receive
//try this first create a callback object which will receive envelope in
onComplete
class MyCallback extends Callback {
public void onComplete(AsyncResult result) {
// Get the response SOAP envelope from the result.
SOAPEnvelope envelope = result.getResponseEnvelope();
log.debug("OnComplete has received the envelope from Axis2 Engine
envelope="+envelope);
// Process SOAP envelope.
}
public void onError(Exception e) {
// Write here what you want to do in case of an error.
log.debug("AXIS2 Engine has produced an error message="+e.getMessage());
}
}
//client code informs client to use 2 separate channels one for send and for
receive
//with client.setUseSeparateListener(true)
try {
// first create the payload of the message
OMElement payload = getPayload(); // add your payload here
// create an instance of service client
ServiceClient serviceClient = new ServiceClient();
// create an options object to pass parameters to service client
Options options = new Options();
// set EPR of the web service
options.setTo(new EndpointReference
("http://www.sample-web-service.com/StockQuote/getQuote"));
// inform Axis2 engine that you need to use a different channel for the
response
options.setUseSeparateListener(true);
// Create a callback object which will receive response in onComplete or
exception in onError
Callback callback = new MyCallback();
//But for the 2 channel approach to work, there
// should be a message correlation mechanism. Apache Axis2 uses the
WS-Addressing
// specification for message correlation so lets engage addressing module here
serviceClient.engageModule(Constants.MODULE_ADDRESSING);
//set the options for the client (useSeparateListener)
serviceClient.setOptions(options);
// invoke service apprising callback object when transport has completed (or
errored out)
serviceClient.sendReceiveNonBlocking(payload, callback);
//use callback.isComplete to determine when the callback has completed
processing e.g.
while(callback.isComplete()==false) ; //tarry here until the transport has
received its envelope
} catch (AxisFault axisFault) {
axisFault.printStackTrace();
}
does this help?
Martin Gainty
______________________________________________
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger
sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung
oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem
Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung.
Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung
fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le
destinataire prévu, nous te demandons avec bonté que pour satisfaire informez
l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est
interdite. Ce message sert à l'information seulement et n'aura pas n'importe
quel effet légalement obligatoire. Étant donné que les email peuvent facilement
être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité
pour le contenu fourni.
Date: Fri, 4 Mar 2011 14:54:21 +0100
Subject: Re: Axis2 client multithreaded asynchronous calls
From: [email protected]
To: [email protected]
Hello Martin,
Thanks a lot for your help.
My Axis2 client will send an HTTP request to a remote asynchronous SOAP Web
Service.
Christophe.
2011/3/4 Martin Gainty <[email protected]>
which transport will your application be implementing
(http/smtp/some_other_transport) ?
if you have seelected http-transport which container will you be implementing
(TC/GF/WS/WL?)
thanks,
Martin
______________________________________________
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger
sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung
oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem
Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung.
Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung
fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le
destinataire prévu, nous te demandons avec bonté que pour satisfaire informez
l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est
interdite. Ce message sert à l'information seulement et n'aura pas n'importe
quel effet légalement obligatoire. Étant donné que les email peuvent facilement
être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité
pour le contenu fourni.
Date: Fri, 4 Mar 2011 14:31:16 +0100
Subject: Axis2 client multithreaded asynchronous calls
From: [email protected]
To: [email protected]
Hello,
I'm trying to understand how to develop an Axis2 client that uses asynchronous
nonBlocking calls from a number of client threads.
In the context of a single thread, I suppose that the following method will
automatically creates a CallbackReceiver ?
serviceClient.sendReceiveNonBlocking(payload, callback);
But in the context of many thread, do I need to use a single CallbackReceiver
for all the threads ? So how can I implement the
http://www.ibm.com/developerworks/webservices/library/ws-axis2/ in the case of
multi threads ?
Thank you very much for your help.
Kind regards,
--
Christophe Noël
-------------------------
--
Christophe Noël
-------------------------
Please consider the environment before printing this email.
--
Christophe Noël
-------------------------
Please consider the environment before printing this email.