axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Gainty <>
Subject RE: [Axis2] Asynchronous Invocation of OperationClient
Date Thu, 24 Feb 2011 21:11:50 GMT

1)construct a payload element which will contain the soap message you want to send to the
awaiting Axis service supply the 2nd parameter to
2)call opClient.sendReceiveNonBlocking(ANON_OUT_IN_OP,parentElementToSend,callback);

    * here is the sendReceiveNonBlocking method
     * Directly invoke a named operation with an In-Out MEP without waiting for a response.
     * method sends your supplied XML with response notification to your callback handler.
For more
     * control, you can instead create a client for the operation and use that client to execute
     * exchange.
     * @param operation name of operation to be invoked (non-<code>null</code>)
     * @param elem      the data to send (becomes the content of SOAP body)
     * @param callback  a Callback which will be notified upon completion
     * @throws AxisFault in case of error
     * @see #createClient(QName)
     * @deprecated Please use the AxisCallback interface rather than Callback, which has been
     *             deprecated
    public void sendReceiveNonBlocking(QName operation, OMElement elem, Callback callback)
            throws AxisFault {
        MessageContext mc = new MessageContext();
        fillSOAPEnvelope(mc, elem);
        OperationClient mepClient = createClient(operation);
        // here a blocking invocation happens in a new thread, so the
        // progamming model is non blocking


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

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


ServiceClient sc = new ServiceClient();
OperationClient opClient = sc.createClient(

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(



outMsgCtx.setEnvelope(createSOAPEnvelope);//createSOAPEnvelope returns soap envelope

// opClient.setCallback(callBack);
//construct your parentElementToSend payload and supply that as 2nd parameter
//here is an example from MexClient
//change your namespace to match the namespace you are using
//change the 1st parameter of createOMElement to be the actual payload you are sending..
        OMFactory fac = OMAbstractFactory.getOMFactory();
//create namespace from factory
        OMNamespace omNs = fac.createOMNamespace(DRConstants.SPEC.NS_URI,DRConstants.SPEC.NS_PREFIX);
//create element from factory
        OMElement parentElementToSend = fac.createOMElement(DRConstants.SPEC.GET_METADATA,



However when I call this client my callback class is not called.
Can one kindly guide me what I am doing wrong here?


Sardar Hussain

View raw message