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);
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