Examples of RPCServiceClient


Examples of org.apache.axis2.rpc.client.RPCServiceClient

        return staxOMBuilder.getDocumentElement();
    }


    public void testechoEmployee() throws Exception {
        RPCServiceClient sender = getRPCClient("EchoXMLService", "echoEmployee");
        OMFactory fac = OMAbstractFactory.getOMFactory();

        OMNamespace omNs = fac.createOMNamespace(NAMESPACE, "my");
        OMElement method = fac.createOMElement("echoEmployee", omNs);

        OMElement value = fac.createOMElement("arg0", null);
        value.addAttribute(fac.createOMAttribute("href", null, "#1"));
        method.addChild(value);


        SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
        SOAPEnvelope envelope = factory.getDefaultEnvelope();
        envelope.getBody().addChild(method);


        String str = "<reference id=\"1\">\n" +
                " <name>John</name>\n" +
                " <age>50</age>\n" +
                " <emplyer href=\"#1\"/>\n" +
                " <address href=\"#2\"/>\n" +
                "</reference>";
        envelope.getBody().addChild(getOMElement(str, fac));
        str = "<reference id=\"2\">\n" +
                "<town>Colombo3</town><number>1010</number>\n" +
                "</reference>";
        envelope.getBody().addChild(getOMElement(str, fac));

        MessageContext reqMessageContext = new MessageContext();
        OperationClient opClinet = sender.createClient(ServiceClient.ANON_OUT_IN_OP);
       
        reqMessageContext.setEnvelope(envelope);

        opClinet.addMessageContext(reqMessageContext);
        opClinet.execute(true);
View Full Code Here

Examples of org.apache.axis2.rpc.client.RPCServiceClient

        assertNotNull(emp);
    }


    public void testMulitrefArray() throws AxisFault {
        RPCServiceClient sender = getRPCClient("EchoXMLService", "handleArrayList");
        OMFactory fac = OMAbstractFactory.getOMFactory();

        OMNamespace omNs = fac.createOMNamespace(NAMESPACE, "my");
        OMElement method = fac.createOMElement("handleArrayList", omNs);

        OMElement value = fac.createOMElement("arg0", null);
        value.addAttribute(fac.createOMAttribute("href", null, "#1"));
        method.addChild(value);

        OMElement value2 = fac.createOMElement("arg1", null);
        value2.setText("10");
        method.addChild(value2);


        SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
        SOAPEnvelope envelope = factory.getDefaultEnvelope();
        envelope.getBody().addChild(method);


        String str = "<reference id=\"1\">\n" +
                "    <item0>abc</item0>\n" +
                "    <item0>def</item0>\n" +
                "    <item0>ghi</item0>\n" +
                "    <item0>klm</item0>\n" +
                "</reference>";
        StAXOMBuilder staxOMBuilder;
        try {
            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new
                    ByteArrayInputStream(str.getBytes()));
            staxOMBuilder = new
                    StAXOMBuilder(fac, xmlReader);
        } catch (XMLStreamException e) {
            throw AxisFault.makeFault(e);
        } catch (FactoryConfigurationError factoryConfigurationError) {
            throw AxisFault.makeFault(factoryConfigurationError);
        }
        envelope.getBody().addChild(staxOMBuilder.getDocumentElement());

        MessageContext reqMessageContext = new MessageContext();
        OperationClient opClinet = sender.createClient(ServiceClient.ANON_OUT_IN_OP);
       
        reqMessageContext.setEnvelope(envelope);

        opClinet.addMessageContext(reqMessageContext);
        opClinet.execute(true);
View Full Code Here

Examples of org.apache.axis2.rpc.client.RPCServiceClient

        // Constructing the arguments array for the method invocation
        Object[] opAddEntryArgs = new Object[] { entry };

        // Invoking the method
        RPCServiceClient serviceClient = getRPCClient();
        Options options = serviceClient.getOptions();
        EndpointReference targetEPR = new EndpointReference(
                "local://services/AddressBookService");
        options.setTo(targetEPR);
        options.setAction("addEntry");

        Object[] ret = serviceClient.invokeBlocking(opAddEntry, opAddEntryArgs, new Class[]{Integer.class});
        assertEquals(ret[0], new Integer(1));

        QName opFindEntry = new QName("http://rpc.axis2.apache.org", "findEntry");
        String name = "Abby Cadabby";

        Object[] opFindEntryArgs = new Object[] { name };
        Class[] returnTypes = new Class[] { Entry.class };

        RPCServiceClient serviceClient2 = getRPCClient();
        Options options2 = serviceClient2.getOptions();
        EndpointReference targetEPR2 = new EndpointReference(
                "local://services/AddressBookService");
        options2.setTo(targetEPR2);
        options2.setAction("findEntry");
        Object[] response = serviceClient2.invokeBlocking(opFindEntry,
                opFindEntryArgs, returnTypes);

        Entry result = (Entry) response[0];
        assertNotNull(result);
View Full Code Here

Examples of org.apache.axis2.rpc.client.RPCServiceClient

        QName opAddEntry = new QName("http://rpc.axis2.apache.org", "getEntries1");

        Object[] opAddEntryArgs = new Object[] { };

        // Invoking the method
        RPCServiceClient serviceClient = getRPCClient();
        Options options = serviceClient.getOptions();
        EndpointReference targetEPR = new EndpointReference(
                "local://services/AddressBookService");
        options.setTo(targetEPR);
        options.setAction("getEntries1");

        Object[] result = serviceClient.invokeBlocking(opAddEntry, opAddEntryArgs, new Class[]{Entry[].class});
        assertNotNull(result);
        Entry[] entries = (Entry[]) result[0];
        assertEquals(entries.length, 2);
    }
View Full Code Here

Examples of org.apache.axis2.rpc.client.RPCServiceClient

        QName opAddEntry = new QName("http://rpc.axis2.apache.org", "getEntries2");

        Object[] opAddEntryArgs = new Object[] { };

        // Invoking the method
        RPCServiceClient serviceClient = getRPCClient();
        Options options = serviceClient.getOptions();
        EndpointReference targetEPR = new EndpointReference(
                "local://services/AddressBookService");
        options.setTo(targetEPR);
        options.setAction("getEntries2");

        Object[] result = serviceClient.invokeBlocking(opAddEntry, opAddEntryArgs, new Class[]{Entry[].class});
        assertNotNull(result);
        Entry[] entries = (Entry[]) result[0];
        assertEquals(entries.length, 0);
    }
View Full Code Here

Examples of org.apache.axis2.rpc.client.RPCServiceClient

        QName opAddEntry = new QName("http://rpc.axis2.apache.org", "getEntries3");

        Object[] opAddEntryArgs = new Object[] { };

        // Invoking the method
        RPCServiceClient serviceClient = getRPCClient();
        Options options = serviceClient.getOptions();
        EndpointReference targetEPR = new EndpointReference(
                "local://services/AddressBookService");
        options.setTo(targetEPR);
        options.setAction("getEntries3");

        Object[] result = serviceClient.invokeBlocking(opAddEntry, opAddEntryArgs, new Class[]{Entry[].class});
        assertNotNull(result);
        Entry[] entries = (Entry[]) result[0];
        assertEquals(entries.length, 0);
    }
View Full Code Here

Examples of org.apache.axis2.rpc.client.RPCServiceClient

     * @return a ServiceClient, pre-initialized to talk using our local sender
     * @throws AxisFault if there's a problem
     */
    protected RPCServiceClient getRPCClient() throws AxisFault {
        Options opts = getOptions();
        RPCServiceClient client = new RPCServiceClient(clientCtx, null);
        client.setOptions(opts);
        return client;
    }
View Full Code Here

Examples of org.apache.axis2.rpc.client.RPCServiceClient

    super.setUp();
    deployClassAsService("EchoXMLService", RPCServiceClass.class);
  }

    public void testEditBean() throws AxisFault {
        RPCServiceClient sender = getRPCClient("EchoXMLService", "editBean");

        MyBean bean = new MyBean();
        bean.setAge(100);
        bean.setName("Deepal");
        bean.setValue(false);
        AddressBean ab = new AddressBean();
        ab.setNumber(1010);
        ab.setTown("Colombo3");
        bean.setAddress(ab);


        ArrayList args = new ArrayList();
        args.add(bean);
        args.add("159");

        OMElement response = sender.invokeBlocking(new QName("http://rpc.axis2.apache.org", "editBean", "req"), args.toArray());
        MyBean resBean = (MyBean)BeanUtil.deserialize(MyBean.class, response.getFirstElement(),
                                                      new DefaultObjectSupplier(), null);
        assertNotNull(resBean);
        assertEquals(resBean.getAge(), 159);
    }
View Full Code Here

Examples of org.apache.axis2.rpc.client.RPCServiceClient

        assertNotNull(resBean);
        assertEquals(resBean.getAge(), 159);
    }

    public void testEchoBean() throws AxisFault {
      RPCServiceClient sender = getRPCClient("EchoXMLService", "echoBean");

        MyBean bean = new MyBean();
        bean.setAge(100);
        bean.setName("Deepal");
        bean.setValue(false);
        AddressBean ab = new AddressBean();
        ab.setNumber(1010);
        ab.setTown("Colombo3");
        bean.setAddress(ab);

        ArrayList args = new ArrayList();
        args.add(bean);


        OMElement response = sender.invokeBlocking(new QName("http://rpc.axis2.apache.org", "echoBean", "req"), args.toArray());
        MyBean resBean = (MyBean)BeanUtil.deserialize(MyBean.class,
                                                      response.getFirstElement(),
                                                      new DefaultObjectSupplier(), null);
//        MyBean resBean =(MyBean) new  BeanSerializer(MyBean.class,response).deserilze();
        assertNotNull(resBean);
View Full Code Here

Examples of org.apache.axis2.rpc.client.RPCServiceClient

        assertNotNull(resBean);
        assertEquals(resBean.getAge(), 100);
    }

    public void testechoMail() throws AxisFault {
      RPCServiceClient sender = getRPCClient("EchoXMLService", "echoMail");

        Mail mail = new Mail();
        mail.setBody("My Body");
        mail.setContentType("ContentType");
        mail.setFrom("From");
        mail.setId("ID");
        mail.setSubject("Subject");
        mail.setTo("To");

        ArrayList args = new ArrayList();
        args.add(mail);


        OMElement response = sender.invokeBlocking(new QName("http://rpc.axis2.apache.org", "echoMail", "req"), args.toArray());
        Mail resBean = (Mail)BeanUtil.deserialize(Mail.class, response.getFirstElement(),
                                                  new DefaultObjectSupplier(), null);
//        MyBean resBean =(MyBean) new  BeanSerializer(MyBean.class,response).deserilze();
        assertNotNull(resBean);
        assertEquals(resBean.getBody(), "My Body");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.