use of org.apache.camel.wsdl_first.PersonService 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.PersonService in project camel by apache.
the class CXFWsdlOnlyPayloadModeNoSpringTest method testRoutes.
@Test
public void testRoutes() throws Exception {
URL wsdlURL = getClass().getClassLoader().getResource("person.wsdl");
PersonService ss = new PersonService(wsdlURL, QName.valueOf(getServiceName()));
Person client = ss.getSoap();
Client c = ClientProxy.getClient(client);
((BindingProvider) client).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + port1 + "/" + getClass().getSimpleName() + "/PersonService");
c.getInInterceptors().add(new LoggingInInterceptor());
c.getOutInterceptors().add(new LoggingOutInterceptor());
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("Bonjour", name.value);
}
use of org.apache.camel.wsdl_first.PersonService in project camel by apache.
the class CxfConsumerPayloadFaultCauseEnabledTest method testInvokingFromCxfClient.
@Test
public void testInvokingFromCxfClient() throws Exception {
this.getCamelContextService();
URL wsdlURL = getClass().getClassLoader().getResource("person.wsdl");
PersonService ss = new PersonService(wsdlURL, SERVICE_QNAME);
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>();
try {
client.getPerson(personId, ssn, name);
fail("SOAPFault expected!");
} catch (Exception e) {
assertTrue(e instanceof SOAPFaultException);
SOAPFault fault = ((SOAPFaultException) e).getFault();
assertEquals("Someone messed up the service. Caused by: Homer", fault.getFaultString());
}
}
use of org.apache.camel.wsdl_first.PersonService 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.PersonService in project camel by apache.
the class CxfBeanTest method testJaxWsBeanFromCxfRoute.
@Test
public void testJaxWsBeanFromCxfRoute() throws Exception {
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:" + CXFTestSupport.getPort1() + "/CxfBeanTest/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("Get a wrong personId", "hello", personId.value);
assertEquals("Get a wrong SSN", "000-000-0000", ssn.value);
assertEquals("Get a wrong name", "Bonjour", name.value);
}
Aggregations