use of org.apache.hello_world_soap_http.Greeter in project cxf by apache.
the class ClientServerTest method testMultiPorts.
@Test
public void testMultiPorts() throws Exception {
URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
assertNotNull(wsdl);
QName sname = new QName("http://apache.org/hello_world_soap_http", "SOAPServiceMultiPortTypeTest");
SOAPServiceMultiPortTypeTest service = new SOAPServiceMultiPortTypeTest(wsdl, sname);
DocLitBare b = service.getDocLitBarePort();
updateAddressPort(b, PORT);
BareDocumentResponse resp = b.testDocLitBare("CXF");
assertNotNull(resp);
assertEquals("CXF", resp.getCompany());
Greeter g = service.getGreeterPort();
updateAddressPort(g, PORT);
String result = g.greetMe("CXF");
assertEquals("Hello CXF", result);
}
use of org.apache.hello_world_soap_http.Greeter in project cxf by apache.
the class ClientServerTest method testGetPortOneParam.
@Test
public void testGetPortOneParam() throws Exception {
URL url = getClass().getResource("/wsdl/hello_world.wsdl");
Service service = Service.create(url, serviceName);
Greeter greeter = service.getPort(Greeter.class);
String response = new String("Bonjour");
try {
((BindingProvider) greeter).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + PORT + "/SoapContext/SoapPort");
greeter.greetMe("test");
String reply = greeter.sayHi();
assertNotNull("no response received from service", reply);
assertEquals(response, reply);
} catch (UndeclaredThrowableException ex) {
throw (Exception) ex.getCause();
}
}
use of org.apache.hello_world_soap_http.Greeter in project cxf by apache.
the class ClientServerTest method testFaults.
@Test
public void testFaults() throws Exception {
URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
assertNotNull(wsdl);
SOAPService service = new SOAPService(wsdl, serviceName);
ExecutorService ex = Executors.newFixedThreadPool(1);
service.setExecutor(ex);
assertNotNull(service);
String noSuchCodeFault = "NoSuchCodeLitFault";
String badRecordFault = "BadRecordLitFault";
Greeter greeter = service.getPort(portName, Greeter.class);
updateAddressPort(greeter, PORT);
for (int idx = 0; idx < 2; idx++) {
try {
greeter.testDocLitFault(noSuchCodeFault);
fail("Should have thrown NoSuchCodeLitFault exception");
} catch (NoSuchCodeLitFault nslf) {
assertNotNull(nslf.getFaultInfo());
assertNotNull(nslf.getFaultInfo().getCode());
}
try {
greeter.testDocLitFault(badRecordFault);
fail("Should have thrown BadRecordLitFault exception");
} catch (BadRecordLitFault brlf) {
BindingProvider bp = (BindingProvider) greeter;
Map<String, Object> responseContext = bp.getResponseContext();
String contentType = (String) responseContext.get(Message.CONTENT_TYPE);
assertEquals("text/xml;charset=utf-8", stripSpaces(contentType.toLowerCase()));
Integer responseCode = (Integer) responseContext.get(Message.RESPONSE_CODE);
assertEquals(500, responseCode.intValue());
assertNotNull(brlf.getFaultInfo());
assertEquals("BadRecordLitFault", brlf.getFaultInfo());
}
}
}
use of org.apache.hello_world_soap_http.Greeter in project cxf by apache.
the class ClientServerTest method testAddPortWithSpecifiedSoap12Binding.
@Test
public void testAddPortWithSpecifiedSoap12Binding() throws Exception {
Service service = Service.create(serviceName);
service.addPort(fakePortName, javax.xml.ws.soap.SOAPBinding.SOAP12HTTP_BINDING, "http://localhost:" + PORT + "/SoapContext/SoapPort");
Greeter greeter = service.getPort(fakePortName, Greeter.class);
String response = new String("Bonjour");
try {
greeter.greetMe("test");
String reply = greeter.sayHi();
assertNotNull("no response received from service", reply);
assertEquals(response, reply);
} catch (UndeclaredThrowableException ex) {
throw (Exception) ex.getCause();
}
}
use of org.apache.hello_world_soap_http.Greeter in project cxf by apache.
the class OutBoundConnectionTest method verifyResult.
private void verifyResult(Object o) throws Exception {
assertTrue("returned connect does not implement Connection interface", o instanceof Connection);
assertTrue("returned connect does not implement Connection interface", o instanceof Greeter);
Greeter greeter = (Greeter) o;
String response = new String("Bonjour");
for (int idx = 0; idx < 5; idx++) {
String reply = greeter.sayHi();
assertNotNull("no response received from service", reply);
assertEquals(response, reply);
}
((Connection) o).close();
}
Aggregations