Just define a new component for rest.

<bean id="restservlet" class="org.apache.camel...ServletComponent">


On Mon, Nov 24, 2014 at 10:26 AM, Pavel Lechev <[email protected]> wrote:
> Hi Claus,
> Thanks for your response.
> Am I to understand that the REST DSL in combination with the `servlet`
> consumer does not allow setting a custom HttpBinding? If so, I believe this
> is a huge limitation given that these two are very commonly used together.
> It is also not very clear from the documentation that Servlet component will
> not allow custom HttpBinding when used in REST DSL.
> Here is my scenario:
> 1. Servlet component explicitly defined in Spring context, where we set the
> http binding:
>     &lt;bean id=&quot;servlet&quot;
> class=&quot;org.apache.camel.component.servlet.ServletComponent&quot;&gt;
> &lt;property name=&quot;httpBinding&quot;&gt;            &lt;bean
> class=&quot;my.custom.HttpBinding&quot;/&gt;        &lt;/property&gt;
> &lt;/bean&gt;
> 2. DSL REST config:
>         restConfiguration()                .component("servlet")  &lt;- use
> the `servlet` component we defined above
> .bindingMode(RestBindingMode.auto);        rest("/my-path")
> .consumes(MediaType.APPLICATION_XML)
> .produces(MediaType.APPLICATION_XML)
> .post().type(MyXMLMappedDataClass.class)                .route()
> .routeId("My-Route")                            .to(....)                     
>           ....                            ....
>         Then, on Spring/Camel startup, the following calls are executed in 
> this
> order:
> 1) component.createEndpoint(..) in DefaultCamelContext.java:525 results in
> endpoint.setBinding(binding) (on ServletComponent.java:96), which
> *correctly* sets my custom binding instance, however the next step
> 2) factory.createConsumer(..) RestEndpoint.java:167 results in
> endpoint.setBinding(new ServletRestHttpBinding()) (on
> ServletComponent.java:208), which overwrites the instance previously set
> I can understand the rationale behind enforcing ServletRestHttpBinding,
> however it will be good if the option to extend this class and configure it
> as a custom binding still exists.
> Thanks
> Pav
>
>
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/Impossible-to-configure-HttpBinding-for-ServletComponent-tp5759473p5759528.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: [email protected]
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/

Reply via email to