Search in sources :

Example 1 with ArrayService

use of org.apache.cxf.jaxws.service.ArrayService in project cxf by apache.

the class CodeFirstTest method testArrayAndList.

@Test
public void testArrayAndList() throws Exception {
    ArrayServiceImpl serviceImpl = new ArrayServiceImpl();
    try (EndpointImpl ep = new EndpointImpl(getBus(), serviceImpl, (String) null)) {
        ep.publish("local://localhost:9090/array");
        ep.getServer().getEndpoint().getInInterceptors().add(new LoggingInInterceptor());
        ep.getServer().getEndpoint().getOutInterceptors().add(new LoggingOutInterceptor());
        QName serviceName = new QName("http://service.jaxws.cxf.apache.org/", "ArrayService");
        QName portName = new QName("http://service.jaxws.cxf.apache.org/", "ArrayPort");
        // need to set the same bus with service , so use the ServiceImpl
        ServiceImpl service = new ServiceImpl(getBus(), (URL) null, serviceName, null);
        service.addPort(portName, "http://schemas.xmlsoap.org/soap/", "local://localhost:9090/array");
        ArrayService proxy = service.getPort(portName, ArrayService.class);
        String[] arrayOut = proxy.arrayOutput();
        assertEquals(arrayOut.length, 3);
        assertEquals(arrayOut[0], "string1");
        assertEquals(arrayOut[1], "string2");
        assertEquals(arrayOut[2], "string3");
        String[] arrayIn = new String[3];
        arrayIn[0] = "string1";
        arrayIn[1] = "string2";
        arrayIn[2] = "string3";
        assertEquals(proxy.arrayInput(arrayIn), "string1string2string3");
        arrayOut = proxy.arrayInputAndOutput(arrayIn);
        assertEquals(arrayOut.length, 3);
        assertEquals(arrayOut[0], "string11");
        assertEquals(arrayOut[1], "string22");
        assertEquals(arrayOut[2], "string33");
        List<String> listOut = proxy.listOutput();
        assertEquals(listOut.size(), 3);
        assertEquals(listOut.get(0), "string1");
        assertEquals(listOut.get(1), "string2");
        assertEquals(listOut.get(2), "string3");
        List<String> listIn = new ArrayList<>();
        listIn.add("list1");
        listIn.add("list2");
        listIn.add("list3");
        assertEquals(proxy.listInput(listIn), "list1list2list3");
    }
}
Also used : ArrayService(org.apache.cxf.jaxws.service.ArrayService) LoggingOutInterceptor(org.apache.cxf.ext.logging.LoggingOutInterceptor) QName(javax.xml.namespace.QName) ArrayServiceImpl(org.apache.cxf.jaxws.service.ArrayServiceImpl) FooServiceImpl(org.apache.cxf.jaxws.service.FooServiceImpl) ArrayList(java.util.ArrayList) LoggingInInterceptor(org.apache.cxf.ext.logging.LoggingInInterceptor) ArrayServiceImpl(org.apache.cxf.jaxws.service.ArrayServiceImpl) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)1 QName (javax.xml.namespace.QName)1 LoggingInInterceptor (org.apache.cxf.ext.logging.LoggingInInterceptor)1 LoggingOutInterceptor (org.apache.cxf.ext.logging.LoggingOutInterceptor)1 ArrayService (org.apache.cxf.jaxws.service.ArrayService)1 ArrayServiceImpl (org.apache.cxf.jaxws.service.ArrayServiceImpl)1 FooServiceImpl (org.apache.cxf.jaxws.service.FooServiceImpl)1 Test (org.junit.Test)1