You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Ed Welch <ed...@edjusted.com> on 2015/07/30 23:20:50 UTC

Rest DSL, HTTP_RESPONSE_CODE and bindings

I'm trying to send a 400 response back to the client, however, I want to send the same body type as registered with outType.

The docs around customer error messages say:

In the UserErrorService bean we build our custom error message, and set the HTTP error code to 400. This is important, as that tells rest-dsl that this is a custom error message, and the message should not use the output pojo binding (eg would otherwise bind to CountryPojo).

So when I set:

exchange.getIn().setHeader(Exchange.HTTP_RESPONSE_CODE, 400);

That tells the rest-dsl to not use the output pojo binding.

Except that's exactly what I want it to do.  

Is there a way to return a 400+ response code AND keep the rest binding mode behavior as if it were a 200?

Thanks!
Ed

Re: Rest DSL, HTTP_RESPONSE_CODE and bindings

Posted by Ed Welch <ed...@edjusted.com>.
Thanks Andy,

This worked great!

On Fri, 31 Jul 2015 00:12:30 -0500, Andrew Block <an...@gmail.com> wrote:

> Ed,
> 
> You can set the skipBindingModeOnErrorCode option to false to leverage the existing binding configuration.
> 
> - Andy
> 
> -- 
> Andrew Block
> 
> 
> On July 30, 2015 at 4:21:00 PM, Ed Welch (ed@edjusted.com) wrote:
> 
> I'm trying to send a 400 response back to the client, however, I want to send the same body type as registered with outType.  
> 
> The docs around customer error messages say:  
> 
> In the UserErrorService bean we build our custom error message, and set the HTTP error code to 400. This is important, as that tells rest-dsl that this is a custom error message, and the message should not use the output pojo binding (eg would otherwise bind to CountryPojo).  
> 
> So when I set:  
> 
> exchange.getIn().setHeader(Exchange.HTTP_RESPONSE_CODE, 400);  
> 
> That tells the rest-dsl to not use the output pojo binding.  
> 
> Except that's exactly what I want it to do.  
> 
> Is there a way to return a 400+ response code AND keep the rest binding mode behavior as if it were a 200?  
> 
> Thanks!  
> Ed



Re: Rest DSL, HTTP_RESPONSE_CODE and bindings

Posted by Andrew Block <an...@gmail.com>.
Ed,

You can set the skipBindingModeOnErrorCode option to false to leverage the existing binding configuration.

- Andy

-- 
Andrew Block


On July 30, 2015 at 4:21:00 PM, Ed Welch (ed@edjusted.com) wrote:

I'm trying to send a 400 response back to the client, however, I want to send the same body type as registered with outType.  

The docs around customer error messages say:  

In the UserErrorService bean we build our custom error message, and set the HTTP error code to 400. This is important, as that tells rest-dsl that this is a custom error message, and the message should not use the output pojo binding (eg would otherwise bind to CountryPojo).  

So when I set:  

exchange.getIn().setHeader(Exchange.HTTP_RESPONSE_CODE, 400);  

That tells the rest-dsl to not use the output pojo binding.  

Except that's exactly what I want it to do.  

Is there a way to return a 400+ response code AND keep the rest binding mode behavior as if it were a 200?  

Thanks!  
Ed