Package org.apache.axis2.client.async

Examples of org.apache.axis2.client.async.Callback


    clientOptions.setTo(new EndpointReference(toEPR));
    clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,toEPR);
    clientOptions.setProperty(Sandesha2ClientAPI.SEQUENCE_KEY,"sequence1")//Optional
    clientOptions.setSoapAction("test:soap:action");
    clientOptions.setProperty(Sandesha2ClientAPI.OFFERED_SEQUENCE_ID,SandeshaUtil.getUUID())//Optional
    Callback callback1 = new TestCallback ("Callback 1");
    call.invokeNonBlocking("echoString", getEchoOMBlock("echo1"),callback1);
    Callback callback2 = new TestCallback ("Callback 2");
    call.invokeNonBlocking("echoString", getEchoOMBlock("echo2"),callback2);
    clientOptions.setProperty(Sandesha2ClientAPI.LAST_MESSAGE, "true");
    Callback callback3 = new TestCallback ("Callback 3");
    call.invokeNonBlocking("echoString", getEchoOMBlock("echo3"),callback3);
   
        while (!callback3.isComplete()) {
            Thread.sleep(1000);
        }
   
    call.close();
  }
View Full Code Here


    clientOptions.setUseSeparateListener(true);
   
    clientOptions.setTo(new EndpointReference(toEPR));
    clientOptions.setProperty(Sandesha2ClientAPI.SEQUENCE_KEY,"sequence1");
    clientOptions.setProperty(Sandesha2ClientAPI.OFFERED_SEQUENCE_ID,SandeshaUtil.getUUID());
    Callback callback1 = new TestCallback ("Callback 1");
    call.invokeNonBlocking("echoString", getEchoOMBlock("echo1"),callback1);
    Callback callback2 = new TestCallback ("Callback 2");
    call.invokeNonBlocking("echoString", getEchoOMBlock("echo2"),callback2);
    clientOptions.setProperty(Sandesha2ClientAPI.LAST_MESSAGE, "true");
    Callback callback3 = new TestCallback ("Callback 3");
    call.invokeNonBlocking("echoString", getEchoOMBlock("echo3"),callback3);
  }
View Full Code Here

            options.setTo(targetEPR);
            options.setAction("urn:echo");
            options.setTransportInProtocol(Constants.TRANSPORT_HTTP);

            //Callback to handle the response
            Callback callback = new Callback() {
                public void onComplete(AsyncResult result) {
                    try {
                        StringWriter writer = new StringWriter();
                        result.getResponseEnvelope().serialize(XMLOutputFactory.newInstance()
                                .createXMLStreamWriter(writer));
                        writer.flush();
                        System.out.println(writer.toString());


                    } catch (XMLStreamException e) {
                        onError(e);
                    }
                }

                public void onError(Exception e) {
                    e.printStackTrace();
                }
            };

            //Non-Blocking Invocation
            sender = new ServiceClient();
            sender.setOptions(options);
            sender.sendReceiveNonBlocking(payload, callback);

            //Wait till the callback receives the response.
            while (!callback.isComplete()) {
                Thread.sleep(1000);
            }

        } catch (AxisFault axisFault) {
            axisFault.printStackTrace();
View Full Code Here

            options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
            options.setUseSeparateListener(true);
            options.setAction("urn:echo");

            //Callback to handle the response
            Callback callback = new Callback() {
                public void onComplete(AsyncResult result) {
                    try {
                        StringWriter writer = new StringWriter();
                        result.getResponseEnvelope().serialize(XMLOutputFactory.newInstance()
                                .createXMLStreamWriter(writer));
                        writer.flush();
                        System.out.println(writer.toString());


                    } catch (XMLStreamException e) {
                        onError(e);
                    }
                }

                public void onError(Exception e) {
                    e.printStackTrace();
                }
            };

            //Non-Blocking Invocation
            sender = new ServiceClient();
            sender.engageModule(new QName(Constants.MODULE_ADDRESSING));
            sender.setOptions(options);
            sender.sendReceiveNonBlocking(payload, callback);

            //Wait till the callback receives the response.
            while (!callback.isComplete()) {
                Thread.sleep(1000);
            }
            //Need to close the Client Side Listener.

        } catch (AxisFault axisFault) {
View Full Code Here

//    clientOptions.setProperty(SandeshaClient.RM_SPEC_VERSION,Sandesha2Constants.SPEC_VERSIONS.v1_1);  //uncomment this to send the messages according to the v1_1 spec.
//    clientOptions.setProperty(SandeshaClient.OFFERED_SEQUENCE_ID,SandeshaUtil.getUUID());  //Uncomment this to offer a sequenceID for the incoming sequence.
   
    serviceClient.setOptions(clientOptions);
   
    Callback callback1 = new TestCallback ("Callback 1");
    serviceClient.sendReceiveNonBlocking(getEchoOMBlock("echo1",sequenceKey),callback1);
   
    clientOptions.setAction("urn:wsrm:EchoString");
    Callback callback2 = new TestCallback ("Callback 2");
    serviceClient.sendReceiveNonBlocking(getEchoOMBlock("echo2",sequenceKey),callback2);
   
    clientOptions.setAction("urn:wsrm:EchoString");
   
    clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true");
    Callback callback3 = new TestCallback ("Callback 3");
    serviceClient.sendReceiveNonBlocking(getEchoOMBlock("echo3",sequenceKey),callback3);
   
        while (!callback1.isComplete() &&
              !callback2.isComplete() &&
              !callback3.isComplete()) {
             Thread.sleep(1000);
        }
       
        Thread.sleep(6000);
       
View Full Code Here

        }

        // THIS NEXT PART WILL EVENTUALLY GO AWAY WHEN Callback DOES

        // OK, this must be an old-style Callback
        Callback callback = (Callback)callbackObj;
        AsyncResult result = new AsyncResult(msgContext);

        // check whether the result is a fault.
        try {
            SOAPEnvelope envelope = result.getResponseEnvelope();

            OperationContext opContext = msgContext.getOperationContext();
            if (opContext != null && !opContext.isComplete()) {
                opContext.addMessageContext(msgContext);
            }

            if (envelope.hasFault()) {
                AxisFault axisFault =
                        Utils.getInboundFaultFromMessageContext(msgContext);
                callback.onError(axisFault);
            } else {
                callback.onComplete(result);
            }
        } catch (Exception e) {
            callback.onError(e);
        finally {
            callback.setComplete(true);
        }
    }
View Full Code Here

        ServiceClient sender = new ServiceClient(configContext, null);
        sender.setOptions(options);
        options.setAction("urn:echoOMElement");
        options.setTo(targetEPR);
        for (int i = 0; i < 5; i++) {
            Callback callback = new Callback() {
                public void onComplete(AsyncResult result) {
                    TestingUtils.compareWithCreatedOMElement(
                            result.getResponseEnvelope()
                                    .getBody().getFirstElement());
                    finish = true;
View Full Code Here

            options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
            options.setUseSeparateListener(true);
            options.setAction(Constants.AXIS2_NAMESPACE_URI + "/" + operationName.getLocalPart());


            Callback callback = new Callback() {
                public void onComplete(AsyncResult result) {
                    TestingUtils.compareWithCreatedOMElement(
                            result.getResponseEnvelope()
                                    .getBody().getFirstElement());
                    finish = true;
View Full Code Here

        Options options = new Options();
        options.setTo(targetEPR);
        options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
        options.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING, MessageContext.UTF_16);

        Callback callback = new Callback() {
            public void onComplete(AsyncResult result) {
                SOAPEnvelope envelope = result.getResponseEnvelope();

                OMElement ele = (OMElement)envelope.getBody().getFirstElement().getFirstOMChild();
                OMText binaryNode = (OMText)ele.getFirstOMChild();
View Full Code Here

            options.setTo(targetEPR);
            options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
            options.setUseSeparateListener(true);
            options.setAction(operationName.getLocalPart());

            Callback callback = new Callback() {
                public void onComplete(AsyncResult result) {
                    TestingUtils.compareWithCreatedOMElement(
                            result.getResponseEnvelope().getBody().getFirstElement());
                    System.out.println("result = "
                            + result.getResponseEnvelope().getBody().getFirstElement());
View Full Code Here

TOP

Related Classes of org.apache.axis2.client.async.Callback

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.