Package org.apache.axis2.client

Examples of org.apache.axis2.client.Call


        LocalTransportReceiver.CONFIG_CONTEXT.getAxisConfiguration()
                .addService(service);
    }

    public void testRPC() throws Exception {
        Call call = new Call("test-resources/xmls");
//        Call call = new Call(".");

        // Make the SOAP envelope
        SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
        SOAPEnvelope env = factory.createSOAPEnvelope();
        factory.createSOAPHeader(env);
        SOAPBody body = factory.createSOAPBody(env);

        // Now set up an RPCRequestElement containing the metadat for our
        // method and an actual set of instance values to serialize.
        RPCValues values = new RPCValues();
        String [] array = new String [] { "one", "two" };
        values.setValue(new QName("string"), array);
        new RPCRequestElement(method, values, body);

        // Ready to go - set the To address and make the call
        Options options = new Options();
        call.setClientOptions(options);
        options.setTo(new EndpointReference("local://services/testService"));
       
        SOAPEnvelope respEnv = call.invokeBlocking("echoArray", env);
        assertNotNull("No response envelope!", respEnv);

        // Got a response envelope, let's deserialize it back to Java
        DeserializationContext dserContext = new DeserializationContext();
        values = dserContext.deserializeRPCElement(method, respEnv.getBody().getFirstElement());
View Full Code Here


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

            Call call = new Call();
            Options options = new Options();
            call.setClientOptions(options);
            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);
            }
View Full Code Here

            Options options = new Options();
            options.setTo(targetEPR);
            options.setListenerTransportProtocol(Constants.TRANSPORT_HTTP);
            options.setUseSeparateListener(true);

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

        } catch (AxisFault axisFault) {
            axisFault.printStackTrace();
        } catch (Exception ex) {
            ex.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();

            Options options = new Options();
            call.setClientOptions(options);
            options.setTo(targetEPR);
            options.setListenerTransportProtocol(Constants.TRANSPORT_HTTP);
            options.setUseSeparateListener(false);

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

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

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

            Call call = new Call();
            Options options = new Options();
            call.setClientOptions(options);
            options.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));
            options.setListenerTransportProtocol(Constants.TRANSPORT_HTTP);
            options.setUseSeparateListener(true);

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

            StringWriter writer = new StringWriter();
            result.serialize(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();
        Options options = new Options();
        call.setClientOptions(options);
        options.setTo(new EndpointReference(toEpr));
        options.setListenerTransportProtocol(Constants.TRANSPORT_TCP);
        options.setUseSeparateListener(false);

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

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

    }

    public OMElement testEchoXMLSync(String fileName) throws Exception {

        OMElement payload = createEnvelope(fileName);
        Call call = new Call();
        Options options = new Options();

        options.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
        options.setTo(targetEPR);
        // enabling MTOM in the client side
        options.setProperty(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_FALSE);
        options.setListenerTransportProtocol(Constants.TRANSPORT_HTTP);
        options.setUseSeparateListener(false);
        call.setClientOptions(options);

        return call.invokeBlocking(operationName
                .getLocalPart(),
                payload);
    }
View Full Code Here

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

        System.out.println("\nTHIS IS A SAMPLE APPLICATION TO DEMONSTRATE THE FUNCTIONALITY OF SERVICE GROUPS");
        System.out.println("===============================================================================");
        Call call = new Call();
        Options options = new Options();
        options.setListenerTransportProtocol(Constants.TRANSPORT_HTTP);
        options.setUseSeparateListener(false);
        call.setClientOptions(options);

        boolean exit = false;
        String serviceGroupContextId = null;
        while (!exit) {
            BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

            System.out.print("\n\nNew round (n) /continue round (c).../exit (e)");
            String option = reader.readLine();
            if ("e".equalsIgnoreCase(option)) {
                System.out.println("Exiting calculator...");
                return;
            }

            if (!"n".equalsIgnoreCase(option) && !"c".equalsIgnoreCase(option)) {
                System.out.println("Error: Invalid option");
                continue;
            }

            System.out.print("Please Select the service ( '+' / '-' / '*' )....");
            String operation = reader.readLine();
            if (!"+".equalsIgnoreCase(operation) && !"-".equalsIgnoreCase(operation) && !"*".equalsIgnoreCase(operation)) {
                System.out.println("Error: Invalid option");
                continue;
            }

            if ("+".equals(operation))
                options.setTo(new EndpointReference(addService));
            else if ("-".equals(operation))
                options.setTo(new EndpointReference(substractService));
            else if ("*".equals(operation))
                options.setTo(new EndpointReference(multiplyService));

            if ("n".equalsIgnoreCase(option)) {
                System.out.print("Enter parameter 1...");
                String param1Str = reader.readLine();
                System.out.print("Enter parameter 2...");
                String param2Str = reader.readLine();
                int param1 = Integer.parseInt(param1Str);
                int param2 = Integer.parseInt(param2Str);

                String opStr = null;
                if ("+".equals(operation)) {
                    opStr = "add";
                } else if ("-".equals(operation)) {
                    opStr = "substract";
                } else if ("*".equals(operation)) {
                    opStr = "multiply";
                }
                System.out.println("Invoking...");
                SOAPEnvelope result = call.invokeBlocking(opStr, getRequestEnvelope(opStr, param1, param2,
                        serviceGroupContextId));
                printResult(result);

                if (serviceGroupContextId == null)
                    serviceGroupContextId = getServiceGroupContextId(result);


            } else if ("c".equalsIgnoreCase(option)) {
                if (serviceGroupContextId == null) {
                    System.out.println("Error: First operation must be a New one. Please select 'n'");
                    continue;
                }

                System.out.print("Enter parameter...");
                String paramStr = reader.readLine();
                int param = Integer.parseInt(paramStr);
                String opStr = null;
                if ("+".equals(operation)) {
                    opStr = "addPrevious";
                } else if ("-".equals(operation)) {
                    opStr = "substractPrevious";
                } else if ("*".equals(operation)) {
                    opStr = "multiplyPrevious";
                }

                System.out.println("Invoking...");
                SOAPEnvelope result = call.invokeBlocking(opStr, getPreviousRequestEnvelope(opStr, param,
                        serviceGroupContextId));
                printResult(result);

            }

View Full Code Here

            throw new FileNotFoundException("Repository Doesnot Exist");
        }
        //copy the LoggingModule.mar to "modules" folder.
        //then modify the axis2.xml that is generating there according to
        //phases that being included in the "module.xml"
        Call call = new Call(repository.getAbsolutePath());
        call.engageModule(new QName("LoggingModule"));
    }
View Full Code Here

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

    public static void main(String[] args) {
        try {
            OMElement payload = ClientUtil.getEchoOMElement();
            Call call = new Call();
            Options options = new Options();
            call.setClientOptions(options);
            options.setTo(targetEPR);
            options.setListenerTransportProtocol(Constants.TRANSPORT_HTTP);
            options.setUseSeparateListener(false);

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

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

TOP

Related Classes of org.apache.axis2.client.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.