title: Apache Camel and CXF : How do i send HTTP status code from bean
body: <p>I have a restful web service based on cxf and camel. I am using Camel routing for my workflow it is something like this.. </p>
  
  <p>Client --> My Rest Service Class --> Camel Custom Processors --> some method Foo of Bean Bar</p>
  
  <p>The bean FooBar looks like something this .. </p>
  
  <pre><code>public class Bar {
  
      public MyObject foo(String request, Exchange exchange){
      //do some procesing 
  
      return instance of MyObject;
  }
  </code></pre>
  
  <p>Now the problem is that whenever i test this i get a respone code of 200 at client side. Now if i want this code to be something else than 200 i need to set it in <code>HttpServletResponse</code> or some other <code>javax.ws.rs.core.Response</code> object but how  i do i access this response object. </p>
  
  <p>I tried the following but it didn't solve my problem.</p>
  
  <ol>
  <li><p><code>exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, 202);</code></p></li>
  <li><p><code>exchange.getIn().setHeader(Exchange.HTTP_RESPONSE_CODE, 202);</code></p></li>
  <li><p><code>exchange.setProperty(Exchange.HTTP_RESPONSE_CODE, 202);</code></p></li>
  <li><p><code>Response.status(202).build();</code></p></li>
  </ol>