Package org.apache.axis2.client.async

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


        options.setTo(targetEPR);
        options.setTransportInfo(Constants.TRANSPORT_HTTP,
                Constants.TRANSPORT_HTTP,
                false);

        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.setListenerTransportProtocol(Constants.TRANSPORT_HTTP);
            options.setUseSeparateListener(false);

            //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) {
                        reportError(e);
                    }
                }

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

            //Non-Blocking Invocation
            call.invokeNonBlocking("echo", payload, callback);

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

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

            Call call = new Call();
            call.setClientOptions(options);

            //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) {
                        reportError(e);
                    }
                }

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

            //Non-Blocking Invocation
            call.invokeNonBlocking("echo", payload, callback);

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

    public void receive(MessageContext messgeCtx) throws AxisFault {
        RelatesTo relatesTO = messgeCtx.getMessageInformationHeaders()
                .getRelatesTo();

        String messageID = relatesTO.getValue();
        Callback callback = (Callback) callbackStore.get(messageID);
        AsyncResult result = new AsyncResult(messgeCtx);
        if (callback != null) {
            callback.onComplete(result);
            callback.setComplete(true);
        } else {
            throw new AxisFault(
                    "The Callback realtes to MessageID " + messageID +
                    " is not found");
        }
View Full Code Here

        options.setTo(targetEPR);
        options.setTransportInfo(Constants.TRANSPORT_MAIL,
                Constants.TRANSPORT_MAIL,
                true);
        call.setClientOptions(options);
        Callback callback = new Callback() {
            public void onComplete(AsyncResult result) {
                try {
                    result.getResponseEnvelope().serializeAndConsume(
                                    XMLOutputFactory.newInstance()
                            .createXMLStreamWriter(System.out));
View Full Code Here

        Call call = new Call(clientHome);
        call.setClientOptions(clientOptions);


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

                OMElement data = (OMElement) envelope.getBody().getFirstElement().getFirstOMChild();
                compareWithCreatedOMText(data.getText());
View Full Code Here

            Options options = new Options();
            call.setClientOptions(options);
            options.setTo(targetEPR);
            options.setTransportInfo(Constants.TRANSPORT_MAIL,
                    Constants.TRANSPORT_MAIL, true);
            Callback callback = new Callback() {
                public void onComplete(AsyncResult result) {
                    resultElem = result.getResponseEnvelope();
                    finish = true;
                }
View Full Code Here

            options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
            options.setUseSeparateListener(true);
            options.setAction("urn:echo")// this is the action mapping we put within the service.xml

            //Callback to handle the response
            Callback callback = new Callback() {
                public void onComplete(AsyncResult result) {
                    System.out.println(result.getResponseEnvelope());
                }

                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

            OMElement payload = ClientUtil.getEchoOMElement();
            Options options = new Options();
            options.setTo(targetEPR);

            //Callback to handle the response
            Callback callback = new Callback() {
                public void onComplete(AsyncResult result) {
                    System.out.println(result.getResponseEnvelope());
                }

                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

    }

    public void receive(MessageContext messageCtx) throws AxisFault {
        RelatesTo relatesTO = messageCtx.getOptions().getRelatesTo();
        String messageID = relatesTO.getValue();
        Callback callback = (Callback) callbackStore.get(messageID);
    AsyncResult result = new AsyncResult(messageCtx);

    if (callback != null) {
      try {
        // check weather the result is a fault.
        SOAPEnvelope envelope = result.getResponseEnvelope();
        SOAPFault fault = envelope.getBody().getFault();

        if (fault == null) {
          // if there is not fault call the onComplete method
          callback.onComplete(result);
        } else {
          // else call the on error method with the fault
          AxisFault axisFault = new AxisFault(fault.getCode(), fault
              .getReason(), fault.getNode(), fault.getRole(),
              fault.getDetail());

          callback.onError(axisFault);
        }
      } finally {
        callback.setComplete(true);
      }
    } else {
            throw new AxisFault("The Callback realtes to MessageID " + messageID + " is not found");
        }
    }
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.