The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

megachucky (17) [Avatar] Offline

unfortunately, there is no full example for using XStream.

I wanna do the following (and I am not sure, if it is possible without JAXB):
A bean "" has two attributes with getters and setters.

public class HelloBean {

private String testAttribute;

private String oneMoreAttribute;

public HelloBean() {


public String hello(String name) {
return "Hello: " + name;

I want to get an XML file, approximately:

This should work with XStream, right?

I use the following route:

// bean(HelloBean.class, "hello").
process(new LogUnknownOrderProcessor());

My template-producer:
template.sendBodyAndHeader("directsmiliexx", "this is a bean to xml transformation",
Exchange.BEAN_METHOD_NAME, "hello");

The output is:
BodyType:byte[], Body:<?xml version='1.0' encoding='UTF-8'?><string>Hello: this is a bean to xml transformation</string>

So, calling the hello-method works. But what route do I have to use to get the desired output:


??? Or is this not possible without JAXB?

Thanks for help in advance...

Best regards, Kai.

Message was edited by:
davsclaus (413) [Avatar] Offline
Re: Section 3.3.2: Transforming using XStream
It doesn't work because you hello method on the HelloBean return a String. So the XStream gets a String to marshal. Instead what you want is to set a bean instance as the body of the message.

For example you can change the code in hello to return a HelloBean

public HelloBean hello(String name) {
HelloBean answer = new HelloBean();
return answer;

Then XStream has a HelloBean as the message body to marshal.

Also a good idea is to check the unit tests of a given Camel component. If neither the book, nor the component documentation helps you.