问题描述
我正在运行的ServiceMix 4.4.1。我试图用骆驼http4做一个HTTP调用到网站。无论我尝试调用哪个网站,我不断收到此错误:
org.apache.camel.RuntimeCamelException:org.apache.camel.component.http.HttpOperationFailedException:HTTP操作失败调用的与状态code:405
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
下面是我的code片断:
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>
我已经尝试了一些网站,并使用不同的HTTP方法(POST VS GET)试过了,我不断收到同样的错误。任何想法?先谢谢了。
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.
推荐答案
在指定的网站上没有一种形式的目标。因此,最有可能将只允许GET请求不是POST。因此,尝试设置CamelHttpMethod就搞定了。
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.
顺便说一句。你想要什么,以实现与您的路线?如果您想发送ActiveMQ消息的网站,那么POST是好的,但你必须使用一个网站,接受POST。
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.
然后就可以发送到URL中的第一条路线。
Then you can send to that url in the first route.
这篇关于获取org.apache.camel.component.http.HttpOperationFailedException与状态code 405的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!