use of org.apache.camel.wsdl_first.JaxwsTestHandler in project camel by apache.
the class AbstractCxfWsdlFirstTest method testInvokingServiceFromCXFClient.
@Test
public void testInvokingServiceFromCXFClient() throws Exception {
JaxwsTestHandler fromHandler = getMandatoryBean(JaxwsTestHandler.class, "fromEndpointJaxwsHandler");
fromHandler.reset();
JaxwsTestHandler toHandler = getMandatoryBean(JaxwsTestHandler.class, "toEndpointJaxwsHandler");
toHandler.reset();
URL wsdlURL = getClass().getClassLoader().getResource("person.wsdl");
PersonService ss = new PersonService(wsdlURL, new QName("http://camel.apache.org/wsdl-first", "PersonService"));
Person client = ss.getSoap();
((BindingProvider) client).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + getPort2() + "/" + getClass().getSimpleName() + "/PersonService/");
Holder<String> personId = new Holder<String>();
personId.value = "hello";
Holder<String> ssn = new Holder<String>();
Holder<String> name = new Holder<String>();
client.getPerson(personId, ssn, name);
assertEquals("we should get the right answer from router", "Bonjour", name.value);
personId.value = "";
try {
client.getPerson(personId, ssn, name);
fail("We expect to get the UnknowPersonFault here");
} catch (UnknownPersonFault fault) {
// We expect to get fault here
}
personId.value = "Invoking getPerson with invalid length string, expecting exception...xxxxxxxxx";
try {
client.getPerson(personId, ssn, name);
fail("We expect to get the WebSerivceException here");
} catch (WebServiceException ex) {
// Caught expected WebServiceException here
assertTrue("Should get the xml vaildate error! " + ex.getMessage(), ex.getMessage().indexOf("MyStringType") > 0 || ex.getMessage().indexOf("Could not parse the XML stream") != -1);
}
verifyJaxwsHandlers(fromHandler, toHandler);
}
use of org.apache.camel.wsdl_first.JaxwsTestHandler in project camel by apache.
the class CxfSoapMessageProviderTest method testSOAPMessageModeDocLit.
@Test
public void testSOAPMessageModeDocLit() throws Exception {
JaxwsTestHandler fromHandler = getMandatoryBean(JaxwsTestHandler.class, "fromEndpointJaxwsHandler");
fromHandler.reset();
QName serviceName = new QName("http://apache.org/hello_world_soap_http", "SOAPProviderService");
QName portName = new QName("http://apache.org/hello_world_soap_http", "SoapProviderPort");
URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
assertNotNull(wsdl);
SOAPService service = new SOAPService(wsdl, serviceName);
assertNotNull(service);
String response1 = new String("TestSOAPOutputPMessage");
String response2 = new String("Bonjour");
try {
Greeter greeter = service.getPort(portName, Greeter.class);
((BindingProvider) greeter).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + port + "/CxfSoapMessageProviderTest/SoapContext/SoapProviderPort");
for (int idx = 0; idx < 2; idx++) {
String greeting = greeter.greetMe("Milestone-" + idx);
assertNotNull("no response received from service", greeting);
assertEquals(response1, greeting);
String reply = greeter.sayHi();
assertNotNull("no response received from service", reply);
assertEquals(response2, reply);
}
} catch (UndeclaredThrowableException ex) {
throw (Exception) ex.getCause();
}
assertEquals("Can't get the right message count", fromHandler.getMessageCount(), 8);
assertEquals("Can't get the right fault count", fromHandler.getFaultCount(), 0);
//From CXF 2.2.7 the soap handler's getHeader() method will not be called if the SOAP message don't have headers
//assertEquals("Can't get the right headers count", fromHandler.getGetHeadersCount(), 4);
}
Aggregations