0

I'm trying to perform one redirection using Apache Camel, but I'm not able to do this, because every time it's showing me GET method, but I have to redirect using POST method.

public void redirectFromSuccess(Exchange exchange) {
    exchange.getIn().setHeader("CamelHttpMethod", "POST");
    exchange.getIn().setHeader("Location","http://testURL.com/SuccessURL");
    exchange.getIn().setHeader(Exchange.HTTP_RESPONSE_CODE,"301");

}
Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197

2 Answers2

0

You have to set method as follows: exchange.getIn().setHeader("CamelHttpMethod", "POST");

Vishal Maral
  • 1,279
  • 1
  • 10
  • 30
0

Try in this way :

public void redirectFromSuccess(Exchange exchange) {
    exchange.getIn().setHeader(Exchange.HTTP_METHOD, constant("POST")); 
    exchange.getIn().setHeader(Exchange.HTTP_URI,"http://testURL.com/SuccessURL");
    exchange.getIn().setHeader(Exchange.HTTP_RESPONSE_CODE,"301");

}

Here is another very simple example :

from("direct:start")
 .setHeader(Exchange.HTTP_METHOD, constant("POST"))
 .to("http://www.google.co.in");
Jimmy
  • 995
  • 9
  • 18