4

I am running servicemix 4.4.1. I am trying to make a http call to a website by using camel-http4. No matter which website I try to invoke, I keep getting this error: org.apache.camel.RuntimeCamelException: org.apache.camel.component.http.HttpOperationFailedException: HTTP operation failed invoking http://servicemix.apache.org/downloads/servicemix-4.4.0.html with statusCode: 405

Here is my code snippet:

 <camelContext xmlns="http://camel.apache.org/schema/spring">
  <route>
    <from uri="activemq://events1"/>
<setHeader headerName="CamelHttpMethod">
    <constant>POST</constant>
</setHeader>
    <to uri="http://servicemix.apache.org/downloads/servicemix-4.4.0.html"/>
    <to uri="log:events"/>
  </route>
</camelContext>

I have tried a number of sites and tried using different http methods (post vs get), and I keep getting the same error. Any idea? Thanks in advance.

рüффп
  • 4,475
  • 34
  • 62
  • 99
emmitt1219
  • 45
  • 1
  • 4

2 Answers2

2

I checked this; problem solved by set option 'bridgeEndpoint'; You are setting the http endpoint to be bridgeEndpoint which means the request url will be updated with request URI.

<route>
   <from uri="-------"/>
   <to uri="jetty://http://localhost:9090/my.html?bridgeEndpoint=true"/
   <to uri="log:events"/>
</route>
Aliti
  • 1,777
  • 2
  • 24
  • 37
2

The website you specified is no target of a form. So most likely it will only allow GET requests not POST. So try to set the CamelHttpMethod to GET.

Btw. what do you want to achieve with your route? If you want to send the activeMQ message to the website then POST is ok but you have to use a website that accepts POST.

You could achieve that by defining your own route to receive the request.

Then you can send to that url in the first route.

Christian Schneider
  • 18,427
  • 2
  • 33
  • 56
  • Thank you for your help. The weird thing is that I thought by not defining CamelHttpMethod, the http method would be assumed to be GET. I tried setting the method to GET explicitly instead of POST and that seemed to have worked. Again, thank you for your help on this. – emmitt1219 Mar 23 '12 at 06:28
  • Camel guesses which http method to use by looking at the url. So it does not always use get by default. See http://camel.apache.org/http.html in the section "Calling using GET or POST" there the algorithm is described. – Christian Schneider May 21 '12 at 09:38