我正在运行servicemix 4.4.1。我正在尝试使用camel-http4对一个网站进行http调用。无论我尝试调用哪个网站,我都会收到这个错误: org.apache.camel.component.http.HttpOperationFailedException: org.apache.camel.RuntimeCamelException操作调用http://servicemix.apache.org/downloads/servicemix-4.4.0.html失败,statusCode: 405
下面是我的代码片段:
<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>
我已经尝试了许多网站,并尝试使用不同的http方法(post和get),但我总是收到相同的错误。有什么想法吗?提前谢谢。
发布于 2012-03-19 14:45:57
您指定的网站不是表单的目标。所以它很可能只允许GET请求,而不允许POST请求。因此,尝试将CamelHttpMethod设置为GET。
顺便说一句。你想通过你的路线达到什么目的?如果你想将activeMQ消息发送到网站,那么POST是可以的,但你必须使用一个接受POST的网站。
您可以通过定义自己的接收请求的路由来实现这一点。
然后,您可以在第一个路由中发送到该url。
发布于 2012-07-01 03:41:27
我对此进行了检查;通过设置选项‘bridgeEndpoint’解决了问题;您正在将http端点设置为bridgeEndpoint,这意味着请求url将使用请求URI进行更新。
<route>
<from uri="-------"/>
<to uri="jetty://http://localhost:9090/my.html?bridgeEndpoint=true"/
<to uri="log:events"/>
</route>
https://stackoverflow.com/questions/9756879
复制相似问题