use of org.apache.camel.wsdl_first.UnknownPersonFault 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.UnknownPersonFault in project camel by apache.
the class CxfConsumerFaultWithRouteTest method createRouteBuilder.
@Override
protected RouteBuilder createRouteBuilder() {
final String serviceURI = "cxf://" + serviceAddress + "?" + PORT_NAME_PROP + "&" + SERVICE_NAME_PROP + "&" + WSDL_URL_PROP + "&serviceClass=org.apache.camel.wsdl_first.Person";
return new RouteBuilder() {
public void configure() {
from(serviceURI).process(new Processor() {
public void process(final Exchange exchange) throws Exception {
// set the fault message here
org.apache.camel.wsdl_first.types.UnknownPersonFault faultDetail = new org.apache.camel.wsdl_first.types.UnknownPersonFault();
faultDetail.setPersonId("");
UnknownPersonFault fault = new UnknownPersonFault("Get the null value of person name", faultDetail);
throw fault;
}
}).to("log:myfaultlog");
}
};
}
use of org.apache.camel.wsdl_first.UnknownPersonFault in project camel by apache.
the class CxfConsumerPayloadFaultTest method testInvokingFromCxfClient.
@Test
public void testInvokingFromCxfClient() throws Exception {
URL wsdlURL = getClass().getClassLoader().getResource("person.wsdl");
PersonService ss = new PersonService(wsdlURL, QName.valueOf(SERVICE_NAME));
Person client = ss.getSoap();
Client c = ClientProxy.getClient(client);
c.getInInterceptors().add(new LoggingInInterceptor());
c.getOutInterceptors().add(new LoggingOutInterceptor());
((BindingProvider) client).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, serviceAddress);
Holder<String> personId = new Holder<String>();
personId.value = "";
Holder<String> ssn = new Holder<String>();
Holder<String> name = new Holder<String>();
Throwable t = null;
try {
client.getPerson(personId, ssn, name);
fail("expect UnknownPersonFault");
} catch (UnknownPersonFault e) {
t = e;
assertEquals("Get the wrong fault detail", "", e.getFaultInfo().getPersonId());
}
assertNotNull(t);
assertTrue(t instanceof UnknownPersonFault);
}
use of org.apache.camel.wsdl_first.UnknownPersonFault in project camel by apache.
the class AbstractCxfWsdlFirstTest method testInvokingServiceWithCamelProducer.
@Test
@SuppressWarnings("unchecked")
public void testInvokingServiceWithCamelProducer() throws Exception {
Exchange exchange = sendJaxWsMessageWithHolders("hello");
assertEquals("The request should be handled sucessfully ", exchange.isFailed(), false);
org.apache.camel.Message out = exchange.getOut();
List<Object> result = out.getBody(List.class);
assertEquals("The result list should not be empty", result.size(), 4);
Holder<String> name = (Holder<String>) result.get(3);
assertEquals("we should get the right answer from router", "Bonjour", name.value);
exchange = sendJaxWsMessageWithHolders("");
assertEquals("We should get a fault here", exchange.isFailed(), true);
Throwable ex = exchange.getException();
assertTrue("We should get the UnknowPersonFault here", ex instanceof UnknownPersonFault);
}
use of org.apache.camel.wsdl_first.UnknownPersonFault in project camel by apache.
the class CXFWsdlOnlyPayloadModeNoSpringTest method testApplicationFault.
@Test
public void testApplicationFault() {
URL wsdlURL = getClass().getClassLoader().getResource("person.wsdl");
PersonService ss = new PersonService(wsdlURL, QName.valueOf(getServiceName()));
Person client = ss.getSoap();
((BindingProvider) client).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + port1 + "/" + getClass().getSimpleName() + "/PersonService");
Client c = ClientProxy.getClient(client);
c.getInInterceptors().add(new LoggingInInterceptor());
c.getOutInterceptors().add(new LoggingOutInterceptor());
Holder<String> personId = new Holder<String>();
personId.value = "";
Holder<String> ssn = new Holder<String>();
Holder<String> name = new Holder<String>();
Throwable t = null;
try {
client.getPerson(personId, ssn, name);
fail("expect UnknownPersonFault");
} catch (UnknownPersonFault e) {
t = e;
}
assertNotNull(t);
assertTrue(t instanceof UnknownPersonFault);
}
Aggregations