use of org.apache.camel.dataformat.soap.name.ServiceInterfaceStrategy in project camel by apache.
the class SoapClientTest method createRouteBuilder.
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
String jaxbPackage = GetCustomersByName.class.getPackage().getName();
@Override
public void configure() throws Exception {
ElementNameStrategy elNameStrat = new ServiceInterfaceStrategy(CustomerService.class, true);
SoapJaxbDataFormat soapDataFormat = new SoapJaxbDataFormat(jaxbPackage, elNameStrat);
final InputStream in = this.getClass().getResourceAsStream("response.xml");
from("direct:start").marshal(soapDataFormat).process(new FileReplyProcessor(in)).unmarshal(soapDataFormat);
}
};
}
use of org.apache.camel.dataformat.soap.name.ServiceInterfaceStrategy in project camel by apache.
the class SoapCxfClientTest method configure.
public void configure() throws Exception {
String jaxbPackage = GetCustomersByName.class.getPackage().getName();
ElementNameStrategy elNameStrat = new ServiceInterfaceStrategy(CustomerService.class, false);
SoapJaxbDataFormat soapDataFormat = new SoapJaxbDataFormat(jaxbPackage, elNameStrat);
getContext().setTracing(true);
//
from("direct:cxfclient").onException(Exception.class).handled(true).marshal(soapDataFormat).end().unmarshal(//
soapDataFormat).bean(//
serverBean).marshal(soapDataFormat);
}
use of org.apache.camel.dataformat.soap.name.ServiceInterfaceStrategy in project camel by apache.
the class SoapCxfServerTest method configure.
public void configure() throws Exception {
String jaxbPackage = GetCustomersByName.class.getPackage().getName();
ElementNameStrategy elNameStrat = new ServiceInterfaceStrategy(CustomerService.class, true);
SoapJaxbDataFormat soapDataFormat = new SoapJaxbDataFormat(jaxbPackage, elNameStrat);
//
from("direct:camelClient").marshal(//
soapDataFormat).to(//
"direct:cxfEndpoint").unmarshal(soapDataFormat);
}
use of org.apache.camel.dataformat.soap.name.ServiceInterfaceStrategy in project camel by apache.
the class ServiceInterfaceStrategyTest method testServiceInterfaceStrategyWithClient.
@Test
public void testServiceInterfaceStrategyWithClient() {
ServiceInterfaceStrategy strategy = new ServiceInterfaceStrategy(CustomerService.class, true);
QName elName = strategy.findQNameForSoapActionOrType("", GetCustomersByName.class);
assertEquals("http://customerservice.example.com/", elName.getNamespaceURI());
assertEquals("getCustomersByName", elName.getLocalPart());
QName elName2 = strategy.findQNameForSoapActionOrType("getCustomersByName", GetCustomersByName.class);
assertEquals("http://customerservice.example.com/", elName2.getNamespaceURI());
assertEquals("getCustomersByName", elName2.getLocalPart());
// Tests the case where the soap action is found but the in type is null
QName elName3 = strategy.findQNameForSoapActionOrType("http://customerservice.example.com/getAllCustomers", null);
assertNull(elName3);
QName elName4 = strategy.findQNameForSoapActionOrType("http://customerservice.example.com/getAllAmericanCustomers", null);
assertNull(elName4);
try {
elName = strategy.findQNameForSoapActionOrType("test", Class.class);
fail();
} catch (RuntimeCamelException e) {
LOG.debug("Caught expected message: " + e.getMessage());
}
}
use of org.apache.camel.dataformat.soap.name.ServiceInterfaceStrategy in project camel by apache.
the class ServiceInterfaceStrategyTest method testServiceInterfaceStrategyWithServer.
@Test
public void testServiceInterfaceStrategyWithServer() {
ServiceInterfaceStrategy strategy = new ServiceInterfaceStrategy(CustomerService.class, false);
// Tests the case where the action is not found but the type is
QName elName = strategy.findQNameForSoapActionOrType("", GetCustomersByNameResponse.class);
assertEquals("http://customerservice.example.com/", elName.getNamespaceURI());
assertEquals("getCustomersByNameResponse", elName.getLocalPart());
// Tests the case where the soap action is found
QName elName2 = strategy.findQNameForSoapActionOrType("http://customerservice.example.com/getCustomersByName", GetCustomersByName.class);
assertEquals("http://customerservice.example.com/", elName2.getNamespaceURI());
assertEquals("getCustomersByNameResponse", elName2.getLocalPart());
// found
try {
elName = strategy.findQNameForSoapActionOrType("test", Class.class);
fail();
} catch (RuntimeCamelException e) {
LOG.debug("Caught expected message: " + e.getMessage());
}
}
Aggregations