我目前正在使用HTTP方法来调用一些将会产生JIRA问题的URL。如何通过Apache Camel调用RESTful服务?
现在我想使用Apache Camel,我该如何使用它?
我需要通过骆驼调用以下链接:
http://localhost:8080/rest/api/2/project/" + key + /components
由于我是新来的骆驼,请提出了一些解决方案和实例了。
感谢
我目前正在使用HTTP方法来调用一些将会产生JIRA问题的URL。如何通过Apache Camel调用RESTful服务?
现在我想使用Apache Camel,我该如何使用它?
我需要通过骆驼调用以下链接:
http://localhost:8080/rest/api/2/project/" + key + /components
由于我是新来的骆驼,请提出了一些解决方案和实例了。
感谢
你可以很容易地使用CXFRS Component;如果你需要使用HTTP Component出于某种原因做它,你可以很容易地使用,以及:
<setHeader headerName="CamelHttpUri">
<simple>http://localhost:8080/rest/api/2/project/${header.myKey}/components</simple>
</setHeader>
<inOut uri="http://doesnt.matter.we/override/it/anyways" />
当然,你需要前往的路线,这部分之前与myKey
头,丰富您的消息。
可以消耗使用CXFRS Component
.Apache骆驼骆驼REST服务有这个足够的信息。
参考这个FAQ关于骆驼 http://camel.apache.org/how-do-i-use-dynamic-uri-in-to.html
使用动态到端点本质上这种情况的EIP模式是收件人列表。
所以你的情况可能也被简化为一个EIP
<recipientList>
<simple>http://localhost:8080/rest/api/2/project/${header.myKey}/components</simple>
</recipientList>
介意骆驼的HTTP组件是完全同步的。如果你想要做的请求/应答通过HTTP和避免使呼叫者块,同时等待应答消息,则可以使用其他一些HTTP组件的从骆驼如:
我使用Apache的骆驼码头
CamelContext context = new DefaultCamelContext();
public void configure(){
context.addRoutes(new RouteBuilder(){
from("jetty:localhost:9000/offers")
.to("direct:getOffers")
.end();
}
});
所以具有 http://localhost:9008/api/v2.0/offers这休息资源getOffers将被调用
所以现在定义getOffers终点
context.addRoutes(new RouteBuilder(){
public void configure(){
from("direct:getOffers")
.to("jetty:http://localhost:9008/api/v2.0/offers?
bridgeEndpoint=true")
.end();
}
});
这里的另一个服务正在运行在9008:在这里,当用户将达到http://localhost:9000/offers则端点直接是我试图消费的资源。
所以当骆驼实例启动时它注册两个途径则它上面
所描述的处理说明其重要补充的选项?bridgeEndpoint = true以使其工作
CXFRS如何用于执行简单的HTTP请求? – Phil 2015-08-17 04:46:08