use of org.apache.camel.dataformat.soap.SoapJaxbDataFormat in project camel by apache.
the class SoapJaxbDataFormatAutoConfiguration method configureSoapJaxbDataFormatFactory.
@Bean(name = "soapjaxb-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(SoapJaxbDataFormat.class)
public DataFormatFactory configureSoapJaxbDataFormatFactory(final CamelContext camelContext, final SoapJaxbDataFormatConfiguration configuration) {
return new DataFormatFactory() {
public DataFormat newInstance() {
SoapJaxbDataFormat dataformat = new SoapJaxbDataFormat();
if (CamelContextAware.class.isAssignableFrom(SoapJaxbDataFormat.class)) {
CamelContextAware contextAware = CamelContextAware.class.cast(dataformat);
if (contextAware != null) {
contextAware.setCamelContext(camelContext);
}
}
try {
Map<String, Object> parameters = new HashMap<>();
IntrospectionSupport.getProperties(configuration, parameters, null, false);
IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), dataformat, parameters);
} catch (Exception e) {
throw new RuntimeCamelException(e);
}
return dataformat;
}
};
}
use of org.apache.camel.dataformat.soap.SoapJaxbDataFormat in project camel by apache.
the class Soap12MarshalTest method createRouteBuilder.
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
SoapJaxbDataFormat df = createDataFormat();
//
from("direct:start").marshal(//
df).to("mock:result");
}
};
}
use of org.apache.camel.dataformat.soap.SoapJaxbDataFormat in project wildfly-camel by wildfly-extras.
the class SOAPIntegrationTest method testSoapUnmarshal.
@Test
public void testSoapUnmarshal() throws Exception {
final SoapJaxbDataFormat format = new SoapJaxbDataFormat();
format.setContextPath("org.wildfly.camel.test.jaxb.model");
CamelContext camelctx = new DefaultCamelContext();
camelctx.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").unmarshal(format);
}
});
camelctx.start();
try (InputStream input = getClass().getResourceAsStream("/envelope.xml")) {
ProducerTemplate producer = camelctx.createProducerTemplate();
Element response = producer.requestBody("direct:start", input, Element.class);
Assert.assertEquals("Customer", response.getLocalName());
} finally {
camelctx.stop();
}
}
use of org.apache.camel.dataformat.soap.SoapJaxbDataFormat in project wildfly-camel by wildfly-extras.
the class SOAPIntegrationTest method testSoapV1_2Marshal.
@Test
public void testSoapV1_2Marshal() throws Exception {
final SoapJaxbDataFormat format = new SoapJaxbDataFormat();
format.setContextPath("org.wildfly.camel.test.jaxb.model");
CamelContext camelctx = new DefaultCamelContext();
camelctx.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").marshal(format);
}
});
camelctx.start();
try (InputStream input = getClass().getResourceAsStream("/envelope-1.2-marshal.xml")) {
String expected = camelctx.getTypeConverter().mandatoryConvertTo(String.class, input);
ProducerTemplate producer = camelctx.createProducerTemplate();
Customer customer = new Customer("John", "Doe");
String customerXML = producer.requestBody("direct:start", customer, String.class);
Assert.assertEquals(expected, XMLUtils.compactXML(customerXML));
} finally {
camelctx.stop();
}
}
use of org.apache.camel.dataformat.soap.SoapJaxbDataFormat in project wildfly-camel by wildfly-extras.
the class SOAPIntegrationTest method testSoapV1_2Unmarshal.
@Test
public void testSoapV1_2Unmarshal() throws Exception {
final SoapJaxbDataFormat format = new SoapJaxbDataFormat();
format.setContextPath("org.wildfly.camel.test.jaxb.model");
format.setVersion("1.2");
CamelContext camelctx = new DefaultCamelContext();
camelctx.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").unmarshal(format);
}
});
camelctx.start();
try (InputStream input = getClass().getResourceAsStream("/envelope-1.2-unmarshal.xml")) {
ProducerTemplate producer = camelctx.createProducerTemplate();
Element response = producer.requestBody("direct:start", input, Element.class);
Assert.assertEquals("Customer", response.getLocalName());
} finally {
camelctx.stop();
}
}
Aggregations