use of org.apache.hello_world_rpclit.SOAPServiceRPCLit in project cxf by apache.
the class ClientServerRPCLitTest method testBasicConnection.
@Test
public void testBasicConnection() throws Exception {
SOAPServiceRPCLit service = new SOAPServiceRPCLit();
assertNotNull(service);
String response1 = new String("Hello Milestone-");
String response2 = new String("Bonjour");
try {
GreeterRPCLit greeter = service.getPort(portName, GreeterRPCLit.class);
ClientProxy.getClient(greeter).getInInterceptors().add(new LoggingInInterceptor());
updateAddressPort(greeter, PORT);
for (int idx = 0; idx < 1; idx++) {
String greeting = greeter.greetMe("Milestone-" + idx);
assertNotNull("no response received from service", greeting);
String exResponse = response1 + idx;
assertEquals(exResponse, greeting);
String reply = greeter.sayHi();
assertNotNull("no response received from service", reply);
assertEquals(response2, reply);
try {
greeter.greetMe("return null");
fail("should catch WebServiceException");
} catch (WebServiceException e) {
// do nothing
} catch (Exception e) {
fail("should catch WebServiceException");
throw e;
}
try {
greeter.greetMe(null);
fail("should catch WebServiceException");
} catch (WebServiceException e) {
// do nothing
} catch (Exception e) {
fail("should catch WebServiceException");
throw e;
}
}
} catch (UndeclaredThrowableException ex) {
throw (Exception) ex.getCause();
}
}
use of org.apache.hello_world_rpclit.SOAPServiceRPCLit in project cxf by apache.
the class ClientServerRPCLitTest method testComplexType.
@Test
public void testComplexType() throws Exception {
SOAPServiceRPCLit service = new SOAPServiceRPCLit();
assertNotNull(service);
GreeterRPCLit greeter = service.getPort(portName, GreeterRPCLit.class);
updateAddressPort(greeter, PORT);
MyComplexStruct in = new MyComplexStruct();
in.setElem1("elem1");
in.setElem2("elem2");
in.setElem3(45);
try {
((BindingProvider) greeter).getRequestContext().put(Message.SCHEMA_VALIDATION_ENABLED, Boolean.TRUE);
MyComplexStruct out = greeter.sendReceiveData(in);
assertNotNull("no response received from service", out);
assertEquals(in.getElem1(), out.getElem1());
assertEquals(in.getElem2(), out.getElem2());
assertEquals(in.getElem3(), out.getElem3());
} catch (UndeclaredThrowableException ex) {
throw (Exception) ex.getCause();
}
try {
in.setElem2("invalid");
greeter.sendReceiveData(in);
} catch (SOAPFaultException f) {
assertTrue(f.getCause() instanceof UnmarshalException);
}
}
use of org.apache.hello_world_rpclit.SOAPServiceRPCLit in project cxf by apache.
the class ClientServerRPCLitTest method testDispatchClient.
@Test
public void testDispatchClient() throws Exception {
SOAPServiceRPCLit service = new SOAPServiceRPCLit();
Dispatch<Source> disp = service.createDispatch(portName, Source.class, javax.xml.ws.Service.Mode.PAYLOAD);
updateAddressPort(disp, PORT);
String req = "<ns1:sendReceiveData xmlns:ns1=\"http://apache.org/hello_world_rpclit\">" + "<in xmlns:ns2=\"http://apache.org/hello_world_rpclit/types\">" + "<ns2:elem1>elem1</ns2:elem1><ns2:elem2>elem2</ns2:elem2><ns2:elem3>45</ns2:elem3>" + "</in></ns1:sendReceiveData>";
Source source = new StreamSource(new StringReader(req));
Source resp = disp.invoke(source);
assertNotNull(resp);
Node nd = StaxUtils.read(resp);
if (nd instanceof Document) {
nd = ((Document) nd).getDocumentElement();
}
XPathUtils xpu = new XPathUtils(new W3CNamespaceContext((Element) nd));
assertTrue(xpu.isExist("/ns1:sendReceiveDataResponse/out", nd, XPathConstants.NODE));
}
use of org.apache.hello_world_rpclit.SOAPServiceRPCLit in project cxf by apache.
the class ProviderRPCClientServerTest method testPayloadModeWithDOMSourceData.
@Test
public void testPayloadModeWithDOMSourceData() throws Exception {
URL wsdl = getClass().getResource("/wsdl/hello_world_rpc_lit.wsdl");
assertNotNull(wsdl);
QName serviceName = new QName("http://apache.org/hello_world_rpclit", "SOAPServiceProviderRPCLit");
QName portName = new QName("http://apache.org/hello_world_rpclit", "SoapPortProviderRPCLit3");
SOAPServiceRPCLit service = new SOAPServiceRPCLit(wsdl, serviceName);
assertNotNull(service);
doGreeterRPCLit(service, portName, 1, true);
}
use of org.apache.hello_world_rpclit.SOAPServiceRPCLit in project cxf by apache.
the class ProviderRPCClientServerTest method testPayloadModeWithSourceData.
@Test
public void testPayloadModeWithSourceData() throws Exception {
URL wsdl = getClass().getResource("/wsdl/hello_world_rpc_lit.wsdl");
assertNotNull(wsdl);
QName serviceName = new QName("http://apache.org/hello_world_rpclit", "SOAPServiceProviderRPCLit");
QName portName = new QName("http://apache.org/hello_world_rpclit", "SoapPortProviderRPCLit8");
SOAPServiceRPCLit service = new SOAPServiceRPCLit(wsdl, serviceName);
assertNotNull(service);
String[] addresses = { "http://localhost:" + PORT + "/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit8", "http://localhost:" + PORT + "/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit8-dom", "http://localhost:" + PORT + "/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit8-sax", "http://localhost:" + PORT + "/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit8-cxfstax", "http://localhost:" + PORT + "/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit8-stax", "http://localhost:" + PORT + "/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit8-stream" };
String response1 = new String("TestGreetMeResponseServerLogicalHandlerServerSOAPHandler");
GreeterRPCLit greeter = service.getPort(portName, GreeterRPCLit.class);
for (String ad : addresses) {
((BindingProvider) greeter).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, ad);
String greeting = greeter.greetMe("Milestone-0");
assertNotNull("no response received from service " + ad, greeting);
assertEquals("wrong response received from service " + ad, response1, greeting);
}
}
Aggregations