On Thu, Feb 24, 2011 at 12:46 PM, Sardar Hussain <[email protected]>wrote:

> Hi,
>
> I am using an OperationClient to invoke different web services
> asynchronously.
> I am passing a callback method to the operationclient as following.
>
> MyCallBack Class:
>
> AxisCallback callBack = new AxisCallback(){
>             public synchronized void onMessage(MessageContext msgContext){
>                 SOAPBody msg = msgContext.getEnvelope().getBody();
>
>                 System.out.println("this is the
> envelope"+msgContext.getEnvelope());
>
>                 System.out.println("Inside onMessage: "+msg);
>
>
>             }
>
>             public void onComplete() {
>                 // TODO Auto-generated method stub
>                 System.out.println("Invocation is complete");
>                  //System.exit(0);
>
>             }
>
>             @Override
>             public void onError(Exception e) {
>                 // TODO Auto-generated method stub
>                 System.out.println("Inside onError: "+e.getMessage());
>             }
>
>             public void onFault(MessageContext msgContext) {
>                 // TODO Auto-generated method stub
>                 System.out.println("Inside onFault:
> "+msgContext.getFailureReason().toString());
>                 msgContext.getFailureReason().printStackTrace();
>             }
>
>         };
>
> ServiceClient sc = new ServiceClient();
>
>        OperationClient opClient = sc.createClient(
>                 ServiceClient.ANON_OUT_IN_OP);
>
> MessageContext outMsgCtx = new MessageContext();
>         //assigning message context's option object into instance variable
>         Options opts = outMsgCtx.getOptions();
>         //setting properties into option
>
>         opts.setTo(new EndpointReference(
>                 endPoint));
>         opts.setAction(action);
>
>  sc.engageModule("addressing");
> opClient.addMessageContext(outMsgCtx);
>
>  opts.setUseSeparateListener(true);
>
> outMsgCtx.setEnvelope(createSOAPEnvelope);//createSOAPEnvelope returns soap
> envelope
>
>  opClient.setCallback(callBack);
>
> opClient.execute(true);
>


 What you can see as the output is correct  :)
 You should use .execute(false) please see
http://axis.apache.org/axis2/java/core/api/org/apache/axis2/client/OperationClient.html#execute%28boolean%29

Thanks !




>
> while(true){
> Thread.sleep(100);
> }
>
>
> However when I call this client my callback class is not called.
> Can one kindly guide me what I am doing wrong here?
>
> Regards,
>
> Sardar Hussain
>
>


-- 
Sagara Gunathunga

Blog - http://ssagara.blogspot.com
Web - http://people.apache.org/~sagara/

Reply via email to