You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Frankiboy <ma...@gmail.com> on 2014/10/29 09:41:55 UTC

I cant throw the correct HTTP status codes from camel.

I cant throw the correct HTTP status codes from camel.


I have a route like this:


 from("direct:channel2").onException(Exception.class).process(new
LogError(HubConstants.CHANNEL2.getValue())).end().recipientList()
                .method(Util.class, "getEndpoint");


The endpoint is down, and i would like to set a responce code 522 back to
the client.


My Exception class is setting the response code like  this:

exchange.getOut().setFault(true);
exchange.getOut().setHeader(org.apache.cxf.message.Message.RESPONSE_CODE,
new Integer(522));


But my client "SOAPUI", still get: 500 back ....


HTTP/1.1 500 Internal Server Error
Content-Type: text/xml; charset=UTF-8
Content-Language: da-DK
Transfer-Encoding: chunked
Connection: Close
Date: Wed, 29 Oct 2014 08:29:06 GMT
Server: WebSphere Application Server/7.0

Heeeelp, any good ideas out there ? 



--
View this message in context: http://camel.465427.n5.nabble.com/I-cant-throw-the-correct-HTTP-status-codes-from-camel-tp5758282.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: I cant throw the correct HTTP status codes from camel.

Posted by Frankiboy <ma...@gmail.com>.
Yes i tried , but i fiend out a solution 


This dosenĀ“t work:

         exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, 522);
         exchange.getOut().setFault(true);

Becouse there is already a exception on the exchange.

But here is the trick, remove the exception that already is on the exchange.

  exchange.removeProperty(Exchange.EXCEPTION_CAUGHT);
  exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, 522);
  exchange.getOut().setFault(true);

now i get a 522 back in the reponse and not a 500 


Thanks out there 



--
View this message in context: http://camel.465427.n5.nabble.com/I-cant-throw-the-correct-HTTP-status-codes-from-camel-tp5758282p5758335.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: I cant throw the correct HTTP status codes from camel.

Posted by Dewitte P-Alban <de...@gmail.com>.
Hi,

Did you tried with exchange.getOut().setHeader(
Exchange.HTTP_RESPONSE_CODE,
new Integer(522));

Best regard

Pierre-Alban DEWITTE
@__pad__

On Wed, Oct 29, 2014 at 5:01 PM, Henryk Konsek <he...@gmail.com> wrote:

> Hi,
>
> >  from("direct:channel2").onException(Exception.class).process(new
> > LogError(HubConstants.CHANNEL2.getValue())).end().recipientList()
> >                 .method(Util.class, "getEndpoint");
>
> Can you share the consumer part of the route with us? :)
>
> Cheers.
>
> --
> Henryk Konsek
> http://henryk-konsek.blogspot.com
>

Re: I cant throw the correct HTTP status codes from camel.

Posted by Henryk Konsek <he...@gmail.com>.
Hi,

>  from("direct:channel2").onException(Exception.class).process(new
> LogError(HubConstants.CHANNEL2.getValue())).end().recipientList()
>                 .method(Util.class, "getEndpoint");

Can you share the consumer part of the route with us? :)

Cheers.

-- 
Henryk Konsek
http://henryk-konsek.blogspot.com