The XStream component provides the XStream data format, which uses the XStream library
to marshal and unmarshal Java objects to and from XML. For example, you can convert a
message body to XML using the xstream() DSL command, as follows:
CamelContext camelctx = new DefaultCamelContext();
camelctx.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start")
.marshal().xstream();
}
});
camelctx.start();
try {
ProducerTemplate producer = camelctx.createProducerTemplate();
String customer = producer.requestBody("direct:start", new Customer("John", "Doe"), String.class);
} finally {
camelctx.stop();
}