use of org.apache.camel.dataformat.soap.name.ServiceInterfaceStrategy in project camel by apache.
the class ServiceInterfaceStrategyTest method testServiceInterfaceStrategyWithRequestWrapperAndClient.
@Test
public void testServiceInterfaceStrategyWithRequestWrapperAndClient() {
ServiceInterfaceStrategy strategy = new ServiceInterfaceStrategy(com.example.customerservice2.CustomerService.class, true);
QName elName = strategy.findQNameForSoapActionOrType("", com.example.customerservice2.GetCustomersByName.class);
assertEquals("http://customerservice2.example.com/", elName.getNamespaceURI());
assertEquals("getCustomersByName", elName.getLocalPart());
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 SoapJaxbDataFormat method unmarshal.
/**
* Unmarshal a given SOAP xml stream and return the content of the SOAP body
* @throws IOException,SAXException
*/
public Object unmarshal(Exchange exchange, InputStream stream) throws IOException, SAXException {
checkElementNameStrategy(exchange);
String soapAction = getSoapActionFromExchange(exchange);
// Determine the method name for an eventual BeanProcessor in the route
if (soapAction != null && elementNameStrategy instanceof ServiceInterfaceStrategy) {
ServiceInterfaceStrategy strategy = (ServiceInterfaceStrategy) elementNameStrategy;
String methodName = strategy.getMethodForSoapAction(soapAction);
exchange.getOut().setHeader(Exchange.BEAN_METHOD_NAME, methodName);
}
// This is necessary as the soap action in the message may get lost on the way
if (soapAction != null) {
exchange.setProperty(Exchange.SOAP_ACTION, soapAction);
}
Object unmarshalledObject = super.unmarshal(exchange, stream);
Object rootObject = JAXBIntrospector.getValue(unmarshalledObject);
return adapter.doUnmarshal(exchange, stream, rootObject);
}
use of org.apache.camel.dataformat.soap.name.ServiceInterfaceStrategy in project camel by apache.
the class MultiPartClientMarshalTest method createRouteBuilder.
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
ServiceInterfaceStrategy strat = new ServiceInterfaceStrategy(com.example.customerservice.multipart.MultiPartCustomerService.class, true);
SoapJaxbDataFormat soapDataFormat = new SoapJaxbDataFormat("com.example.customerservice.multipart", strat);
from("direct:start").marshal(soapDataFormat).log("marshal to: ${body}").end();
}
};
}
use of org.apache.camel.dataformat.soap.name.ServiceInterfaceStrategy in project camel by apache.
the class MultiPartCxfServerTest method configure.
@Override
public void configure() throws Exception {
ServiceInterfaceStrategy strat = new ServiceInterfaceStrategy(com.example.customerservice.multipart.MultiPartCustomerService.class, true);
SoapJaxbDataFormat soapDataFormat = new SoapJaxbDataFormat("com.example.customerservice.multipart", strat);
from("direct:start").marshal(soapDataFormat).log("marshal to: ${body}").to("direct:cxfEndpoint").unmarshal(soapDataFormat).end();
}
use of org.apache.camel.dataformat.soap.name.ServiceInterfaceStrategy in project camel by apache.
the class ServiceInterfaceStrategyTest method testMultiPart.
@Test
public void testMultiPart() {
ServiceInterfaceStrategy strategy = new ServiceInterfaceStrategy(MultiPartCustomerService.class, true);
QName custNameQName = strategy.findQNameForSoapActionOrType("http://multipart.customerservice.example.com/getCustomersByName", com.example.customerservice.multipart.GetCustomersByName.class);
QName custTypeQName = strategy.findQNameForSoapActionOrType("http://multipart.customerservice.example.com/getCustomersByName", com.example.customerservice.multipart.Product.class);
assertEquals("http://multipart.customerservice.example.com/", custNameQName.getNamespaceURI());
assertEquals("getCustomersByName", custNameQName.getLocalPart());
assertEquals("http://multipart.customerservice.example.com/", custTypeQName.getNamespaceURI());
assertEquals("product", custTypeQName.getLocalPart());
}
Aggregations