I have arranged for the following Camel route which unmarshals an XML file into a Java object (com.sample.Order):
<route>
<from uri="file:/data/in?fileName=order.xml&noop=true"/>
<unmarshal ref="transform-xml"/>
<to uri="velocity:etc/MailBody.vm"/>
<to uri="file:/data/out"/>
</route>
Here is the MailBody.vm:
#set( $order = $body.get(0).get('com.sample.Order'))
Order status:
- Id: $order.id
- Price: $order.price
Tax: $order.tax
Details:
$order.description
When the Camel route is executed however the generated XML file does not parse the $order fields. Is there anything I miss or maybe this in not working in my camel version (2.15.3) ? Thanks
Try to modify your template like shown below:
#set( $order = ${body.get(0).get("com.sample.Order")})
Order status:
- Id: ${order.id}
- Price: ${order.price}
Tax: ${order.tax}
Details:
${order.description}