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");
}
}
Aggregations