use of org.apache.camel.model.dataformat.JaxbDataFormat in project camel by apache.
the class ConsumerMarshallingRouteTest method createRouteBuilder.
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
JaxbDataFormat jaxb = new JaxbDataFormat(false);
jaxb.setContextPath("org.apache.camel.component.spring.ws.jaxb");
// request webservice
from("direct:webservice-marshall").marshal(jaxb).to("spring-ws:http://localhost/?soapAction=http://www.stockquotes.edu/GetQuote&webServiceTemplate=#webServiceTemplate").convertBodyTo(String.class);
// request webservice
from("direct:webservice-marshall-unmarshall").marshal(jaxb).to("spring-ws:http://localhost/?soapAction=http://www.stockquotes.edu/GetQuote&webServiceTemplate=#webServiceTemplate").unmarshal(jaxb);
// provide web service
from("spring-ws:soapaction:http://www.stockquotes.edu/GetQuote?endpointMapping=#endpointMapping").process(new StockQuoteResponseProcessor());
// request webservice
from("direct:webservice-marshall-asinonly").marshal(jaxb).to("spring-ws:http://localhost/?soapAction=http://www.stockquotes.edu/GetQuoteAsInOnly&webServiceTemplate=#webServiceTemplate").convertBodyTo(String.class);
// provide web service
from("spring-ws:soapaction:http://www.stockquotes.edu/GetQuoteAsInOnly?endpointMapping=#endpointMapping").setExchangePattern(ExchangePattern.InOnly).process(new StockQuoteResponseProcessor());
// request webservice
from("direct:webservice-marshall-asin").marshal(jaxb).to("spring-ws:http://localhost/?soapAction=http://www.stockquotes.edu/GetQuoteAsIn&webServiceTemplate=#webServiceTemplate").convertBodyTo(String.class);
// provide web service
from("spring-ws:soapaction:http://www.stockquotes.edu/GetQuoteAsIn?endpointMapping=#endpointMapping").setHeader("setin", constant("true")).process(new StockQuoteResponseProcessor());
}
};
}
use of org.apache.camel.model.dataformat.JaxbDataFormat in project wildfly-camel by wildfly-extras.
the class JAXBIntegrationTest method testJaxbUnmarshal.
@Test
public void testJaxbUnmarshal() throws Exception {
final JaxbDataFormat format = new JaxbDataFormat();
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("/customer.xml")) {
ProducerTemplate producer = camelctx.createProducerTemplate();
Customer customer = producer.requestBody("direct:start", input, Customer.class);
Assert.assertEquals("John", customer.getFirstName());
Assert.assertEquals("Doe", customer.getLastName());
} finally {
camelctx.stop();
}
}
use of org.apache.camel.model.dataformat.JaxbDataFormat in project camel by apache.
the class ConsumerBreadcrumbIdTest method createRouteBuilder.
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
JaxbDataFormat jaxb = new JaxbDataFormat(false);
jaxb.setContextPath("org.apache.camel.component.spring.ws.jaxb");
// request webservice
from("direct:webservice-marshall-asin").marshal(jaxb).to("spring-ws:http://localhost/?soapAction=http://www.stockquotes.edu/GetQuoteAsIn&webServiceTemplate=#webServiceTemplate").convertBodyTo(String.class);
// provide web service
from("spring-ws:soapaction:http://www.stockquotes.edu/GetQuoteAsIn?endpointMapping=#endpointMapping").setHeader("setin", constant("true")).process(new StockQuoteResponseProcessor());
}
};
}
use of org.apache.camel.model.dataformat.JaxbDataFormat in project camel by apache.
the class DataFormatClause method jaxb.
/**
* Uses the JAXB data format with context path
*/
public T jaxb(String contextPath) {
JaxbDataFormat dataFormat = new JaxbDataFormat();
dataFormat.setContextPath(contextPath);
return dataFormat(dataFormat);
}
use of org.apache.camel.model.dataformat.JaxbDataFormat in project camel by apache.
the class JaxbMarshalNamespacePrefixMapperTest method createRouteBuilder.
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
JaxbDataFormat df = new JaxbDataFormat();
df.setContextPath("org.apache.camel.example");
df.setNamespacePrefixRef("myPrefix");
from("direct:start").marshal(df).to("mock:result");
}
};
}
Aggregations