如何通过 Apache Camel 调用 RESTful 服务?

问题描述:

我目前正在使用 HTTP 方法来调用一些会产生 JIRA 问题的 URL.

I am currently using a HTTP method for invoking some URL which will create a JIRA issue.

现在我想使用 Apache Camel,我该如何使用?

Now I want to use Apache Camel, how can I use that?

我需要通过 Camel 调用以下链接:

I need to invoke the following link through Camel:

http://localhost:8080/rest/api/2/project/" + key + /components

因为我是 Camel 的新手,所以也请提出一些解决方案和示例.

As I'm new to Camel, please suggest some solutions and examples too.

谢谢

您可以轻松使用 CXFRS 组件;如果您出于某种原因需要使用 HTTP 组件 来执行此操作,您也可以轻松使用它:

You could easily use the CXFRS Component; if you need to do it using the HTTP Component for some reason you could easily use that as well:

<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 标头来丰富您的消息.

And of course you will need to enrich your message with the myKey header before getting to this part of the route.