camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <>
Subject Re: Rest DSL IN/OUT types
Date Tue, 09 Dec 2014 16:01:10 GMT

Ah yeah as it marshalled using JAXB for IN it defaults to do the
reverse on out. But as you have auto mode, we could likely detect that
if the message body does not have @Jaxb annotations it should use it
as-is. Also we could detect if the body is a String and use that
as-is, as its assume xml content to be returned as-is.

On Tue, Dec 9, 2014 at 4:27 PM, Alan Camillo <> wrote:
> Hello!
> I've had some problems trying the new rest dsl from camel and I'd like to
> know if there is a way to do this:
> restConfiguration()
>     .component("netty-http")
>     .host("")
>     .bindingMode(**)
>     .port("{{server.port}}");
> rest("/mail")
>     .post("/send")
>         .consumes("text/xml")
>         .produces("text/xml")
>         .type(A.class)
>         .to("direct:msg");
> Until here I received a A.class from the clients with no problem.
> But from "direct:msg" I'd like to return a (xml) String to the client. Like
> this:
> from("direct:msg").routeId("direct:msg")
>     .log("message received: ${body}")
>     .setBody(new ConstantExpression("<?xml version=\"1.0\"
> encoding=\"UTF-8\"?><ok>ok</ok>"));
> And than, error:
> javax.xml.bind.MarshalException
>  - with linked exception:
> [com.sun.istack.SAXException2: unable to marshal type "java.lang.String" as
> an element because it is missing an @XmlRootElement annotation]
> Look obvious, but I'd like to know if there a way to do this.
> Thanks!
> Alan Camillo

Claus Ibsen
Red Hat, Inc.
Twitter: davsclaus
Author of Camel in Action:

View raw message