camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gary Kennedy <>
Subject Re: Setting rest response json directly
Date Sun, 09 Nov 2014 22:24:21 GMT
I changed the way I used the servlet/rest component and it works for me now.

I'm still using the same bean setup as before:
    <reference id="httpService"
    <bean id="camelServlet" class="...CamelHttpTransportServlet"/>
    <bean id="registration" class="...OsgiServletRegisterer"
                init-method="register" destory-method="unregister">
        <property name="alias" value="/example"/>
        <property name="servletName" value="MyServlet"/>
        <property name="servlet" ref="camelServlet"/>
        <property name="httpService" ref="httpService"/>

But now I've dropped the rest part, and using servlet endpoints to start the
            <json id="json" .../>
            <from uri="servlet:///route?servletName=MyServlet"/>
            <unmarshal ref="json"/>
            < !-- lots of magic -->
                < !-- more magic -->
                <setHeader headerName="Content-Type">
                    <simple>{ "error": "${exception.message}" }</simple>

The bonus to using this method is that the unmarshalling is covered by the
in-route onException block as well.

The downside is that now I have to work on the http method filtering (ie,
making the route POST/GET specific). It might be easier to play with the
consumes/produces part of the rest dsl to bring the above theory used above
into the rest dsl. Anyways,


View this message in context:
Sent from the Camel - Users mailing list archive at

View raw message