使用骆驼调用REST URL

Vir*_*ral 2 java xml rest apache-camel

我需要通过骆驼给我的当地休息处打电话。

当我从浏览器中调用URL时,我得到了答复。

例如

http:// localhost:8081 / buzzor / secure / buzzorapp / getAvailableLanguages

我得到了一个结果:

 [
    {
        "name": "English",
        "value": "en"
    },
    {
        "name": "?????",
        "value": "mr"
    },
    {
        "name": "???????",
        "value": "gu"
    },
    {
        "name": "?????",
        "value": "ta"
    },
    {
        "name": "??????",
        "value": "hi"
    },
    {
        "name": "Français",
        "value": "fr"
    },
    {
        "name": "??????",
        "value": "te"
    }
]
Run Code Online (Sandbox Code Playgroud)

现在我需要从骆驼调用相同的REST URL,为此,我创建了一个路由。

<camelContext xmlns="http://camel.apache.org/schema/spring" trace="false">
    <route>
        <from uri="direct:start" />
        <to uri="http://localhost:8081/buzzor/secure/buzzorapp/getAvailableLanguages" />
    </route>
</camelContext>
Run Code Online (Sandbox Code Playgroud)

执行完此操作后,如果我未调用项目URL。请告诉我我在哪里弄错了。在控制台站点上,我只能得到输出:

[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] <<< camel-maven-plugin:2.15.1:run (default-cli) < test-compile @ CXF-Sample <<<
[INFO] 
[INFO] --- camel-maven-plugin:2.15.1:run (default-cli) @ CXF-Sample ---
[INFO] Using org.apache.camel.spring.Main to initiate a CamelContext
[INFO] Starting Camel ...
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Run Code Online (Sandbox Code Playgroud)

hve*_*iga 5

看起来您正在使用direct端点作为使用者。这意味着您将需要发送一个交换direct:start以触​​发http get。

使用一次运行一次的计时器呢?

<camelContext xmlns="http://camel.apache.org/schema/spring" trace="false">
  <route>
    <from uri="timer:foo?repeatCount=1" />
    <to uri="http://localhost:8081/buzzor/secure/buzzorapp/getAvailableLanguages" />
  </route>
</camelContext>
Run Code Online (Sandbox Code Playgroud)

该路由将运行并调用一次http端点。