Package org.apache.axis2.client.async

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


            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


            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

    }

    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) {
            callback.onComplete(result);
            callback.setComplete(true);
        } else {
            throw new AxisFault("The Callback realtes to MessageID " + messageID + " is not found");
        }
    }
View Full Code Here

                        null) {
                    AxisOperation axisOperation = msgctx.getAxisOperation();
                    if (axisOperation != null) {
                        MessageReceiver msgReceiver = axisOperation.getMessageReceiver();
                        if ((msgReceiver != null) && (msgReceiver instanceof CallbackReceiver)) {
                            Callback callback = ((CallbackReceiver) msgReceiver)
                                    .lookupCallback(msgctx.getMessageID());
                            if (callback != null) {
                                callback.onError(e);
                            }
                        }
                    }
                }
            }
View Full Code Here

        RelatesTo relatesTO = messageCtx.getOptions().getRelatesTo();
        if (relatesTO == null) {
            throw new AxisFault("Cannot identify correct Callback object. RelatesTo is null");
        }
        String messageID = relatesTO.getValue();
        Callback callback = (Callback) callbackStore.remove(messageID);
        AsyncResult result = new AsyncResult(messageCtx);

        if (callback == null) {
            throw new AxisFault("The Callback realtes to MessageID " + messageID + " is not found");
        }
       
        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 = Utils.getInboundFaultFromMessageContext(messageCtx);
                callback.onError(axisFault);
            }
        } finally {
            callback.setComplete(true);
        }
    }
View Full Code Here

            Options options = new Options();
            options.setTo(targetEPR);
            options.setAction("urn:echo");

            //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

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

            deploymentFileData.setClassLoader(isDirectory, getClass().getClassLoader(),
                    (File) cfgCtx.getAxisConfiguration().getParameterValue(
                            Constants.Configuration.ARTIFACTS_TEMP_DIR),
                    cfgCtx.getAxisConfiguration().isChildFirstClassLoading());

            DeploymentClassLoader urlCl
                = (DeploymentClassLoader)deploymentFileData.getClassLoader();
            Thread.currentThread().setContextClassLoader(urlCl);

            // StartupFactory registration
            for (StartupFactory factory : getProviders(StartupFactory.class, urlCl)) {
View Full Code Here

    private void handleException(String message, Exception e) throws DeploymentException {
        if (log.isDebugEnabled()) {
            log.debug(message, e);
        }
        throw new DeploymentException(message, e);
    }
View Full Code Here

    private void handleException(String message, Throwable t) throws DeploymentException {
        if (log.isDebugEnabled()) {
            log.debug(message, t);
        }
        throw new DeploymentException(message, t);
    }
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.