Hello,

What is the easiest way to unmarshall an XML payload to an object without 
having to explicitly create or specify the java class?

I am POCing a REST service that consumes an XML message from an older system.  
In the Camel in Action, 2nd Edition book page 93, it says I can easily use 
XStream to unmarshall from XML to Object.  However when I ran a simple test, it 
throws a com.thoughtworks.xstream.mapper.CannotResolveClassException.

Router:

@Component
public class ClaimSubmitServiceRest extends RouteBuilder {

    @Value("${app.api.path}")
    String contextpath;

    @Override
    public void configure() {

        from("rest:post:submit")
                .unmarshal().xstream()
                .to("direct:continue");

        from("direct:continue")
                .log("*** Unmarshal result: " + body().toString());
    }
Sample request:

<?xml version="1.0" encoding="UTF-8"?>
<WebReqeust>
        <Control>
               <TransactionId>V10101</TransactionId>
               <TransactionType>SynchronousRequest</TransactionType>
               <SourceSystem>
                       <Actor>WebPortal</Actor>
                       <Action>Submit</Action>
               </SourceSystem>
        </Control>
</WebReqeust>

Thanks,
Chris

Reply via email to