Package org.apache.axis2.clientapi

Examples of org.apache.axis2.clientapi.Call


    public static void main(String[] args) {
        try {
            OMElement payload = ClientUtil.getEchoOMElement();

            Call call = new Call();
            call.setTo(targetEPR);
            call.setTransportInfo(Constants.TRANSPORT_HTTP,
                    Constants.TRANSPORT_HTTP,
                    false);

            //Callback to handle the response
            Callback callback = new Callback() {
                public void onComplete(AsyncResult result) {
                    try {
                        StringWriter writer = new StringWriter();
                        result.getResponseEnvelope().serializeWithCache(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);
            }
View Full Code Here


    private void axis2EngineRuns(String operation, OMElement element,
                                 Callback specificCallbackObject) {
        //endpoint uri is hard coded....
        String url = "http://webservices.amazon.com/onca/soap?Service=AWSSimpleQueueService";
        try {
            Call call = new Call();
            call.setSoapAction("http://soap.amazon.com");
            call.setTo(new EndpointReference(url));
            call.setTransportInfo(Constants.TRANSPORT_HTTP,
                    Constants.TRANSPORT_HTTP,
                    false);
            call.invokeNonBlocking(operation, element, specificCallbackObject);
        } catch (AxisFault axisFault) {
            axisFault.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }
View Full Code Here

    public static void main(String[] args) {
        try {
            OMElement payload = ClientUtil.getEchoOMElement();

            Call call = new Call();
            call.setTo(targetEPR);

            //The boolean flag informs the axis2 engine to use two separate transport connection
            //to retrieve the response.
            call.engageModule(new QName(Constants.MODULE_ADDRESSING));
            call.setTransportInfo(Constants.TRANSPORT_HTTP,
                    Constants.TRANSPORT_HTTP,
                    true);

            //Callback to handle the response
            Callback callback = new Callback() {
                public void onComplete(AsyncResult result) {
                    try {
                        StringWriter writer = new StringWriter();
                        result.getResponseEnvelope().serializeWithCache(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();

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

    private void axis2EngineRuns(String operation, OMElement element,
                                 Callback specificCallbackObject) {
        //endpoint uri is hard coded....
        String url = "http://webservices.amazon.com/onca/soap?Service=AWSSimpleQueueService";
        try {
            Call call = new Call();
            call.setSoapAction("http://soap.amazon.com");
            call.setTo(new EndpointReference(url));
            call.setTransportInfo(Constants.TRANSPORT_HTTP,
                    Constants.TRANSPORT_HTTP,
                    false);
            call.invokeNonBlocking(operation, element, specificCallbackObject);
        } catch (AxisFault axisFault) {
            axisFault.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }
View Full Code Here

    private static EndpointReference targetEPR = new EndpointReference("http://localhost:8080/axis2/services/MyService");

    public static void main(String[] args) {
        try {
            OMElement payload = ClientUtil.getEchoOMElement();
            Call call = new Call();
            call.setTo(targetEPR);
            call.setTransportInfo(Constants.TRANSPORT_HTTP,
                    Constants.TRANSPORT_HTTP,
                    false);

            //Blocking invocation
            OMElement result = call.invokeBlocking("echo",
                    payload);

            StringWriter writer = new StringWriter();
            result.serializeWithCache(XMLOutputFactory.newInstance()
                    .createXMLStreamWriter(writer));
View Full Code Here

      // Get the repository location from the args
      String repo = args[0];
      String port = args[1];
     
      OMElement payload = getEchoElement();
      Call call = new Call(repo);
     
      call.setTo(new EndpointReference("http://127.0.0.1:" + port + "/axis2/services/SecureService"));
      call.setTransportInfo(Constants.TRANSPORT_HTTP,
          Constants.TRANSPORT_HTTP, false);
      call.set(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE);

      //Blocking invocation
      OMElement result = call.invokeBlocking("echo", payload);

      StringWriter writer = new StringWriter();
      result.serializeWithCache(XMLOutputFactory.newInstance()
          .createXMLStreamWriter(writer));
      writer.flush();
View Full Code Here

    }


    public void doAsyncSpellingSuggestion(String word) {
        OMElement requestElement = getElement(word);
        Call call = null;
        try {
            call = new Call();
        } catch (AxisFault axisFault) {
            observer.updateError(axisFault.getMessage());
        }
        URL url = null;
        try {
            url =
                    new URL(PROTOCOL,
                            PropertyLoader.getGoogleEndpointURL(),
                            PropertyLoader.getGoogleEndpointServiceName());
            //url=new URL( "http","127.0.0.1",7070,"/search/beta2");
        } catch (MalformedURLException e) {
            observer.updateError(e.getMessage());
            ;
        }

        call.setTo(
                new EndpointReference(url.toString()));
        try {
            call.invokeNonBlocking("doGoogleSpellingSugg",
                    requestElement,
                    new GoogleCallBack(word));
        } catch (AxisFault axisFault) {
            observer.updateError(axisFault.getMessage());
        }
View Full Code Here

    }

    public void doSyncSpellingSuggestion(String word) {
        OMElement responseElement = null;
        OMElement requestElement = getElement(word);
        Call call = null;
        try {
            call = new Call();
        } catch (AxisFault axisFault) {
            observer.updateError(axisFault.getMessage());
        }
        URL url = null;
        try {
            url =
                    new URL(PROTOCOL,
                            PropertyLoader.getGoogleEndpointURL(),
                            PropertyLoader.getGoogleEndpointServiceName());
            //url=new URL( "http","127.0.0.1",7070,"/search/beta2");
        } catch (MalformedURLException e) {
            observer.updateError(e.getMessage());
        }

        call.setTo(
                new EndpointReference(url.toString()));
        try {
            responseElement =
                    call.invokeBlocking("doGoogleSpellingSugg",
                            requestElement);
        } catch (AxisFault axisFault) {
            observer.updateError(axisFault.getMessage());
        }
View Full Code Here

    public static void main(String[] args) {
        try {
            OMElement payload = ClientUtil.getEchoOMElement();

            Call call = new Call();
            call.setTo(targetEPR);

            //The boolean flag informs the axis2 engine to use two separate transport connection
            //to retrieve the response.
            call.engageModule(new QName(Constants.MODULE_ADDRESSING));
            call.setTransportInfo(Constants.TRANSPORT_HTTP,
                    Constants.TRANSPORT_HTTP,
                    true);

            //Blocking Invocation
            OMElement result = call.invokeBlocking("echo",
                    payload);

            StringWriter writer = new StringWriter();
            result.serializeWithCache(XMLOutputFactory.newInstance()
                    .createXMLStreamWriter(writer));
            writer.flush();
            System.out.println(writer.toString());


            //Need to close the Client Side Listener.
            call.close();

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

    private static String toEpr = "tcp://localhost:8080/axis2/services/MyService";

    public static void main(String[] args) throws AxisFault {

        Call call = new Call();
        call.setTo(new EndpointReference(toEpr));
        call.setTransportInfo(Constants.TRANSPORT_TCP,
                Constants.TRANSPORT_TCP,
                false);
        //call.engageModule(new QName(Constants.MODULE_ADDRESSING));

        OMElement result = call.invokeBlocking("echo", getPayload());

        try {
            XMLStreamWriter writer = XMLOutputFactory.newInstance()
                    .createXMLStreamWriter(System.out);
            result.serializeWithCache(writer);
View Full Code Here

TOP

Related Classes of org.apache.axis2.clientapi.Call

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.