java - Apache Camel 和 CXF : Mutlitple cxf:rsServer tags . 。这可能吗?

标签 java rest http-status-code-404 apache-camel cxfrs

我一直在使用 cxf 和 camel 制作 Restful 网络服务,我遇到了一个奇怪的问题,我不知道这是正常的 camel 行为还是什么。

我有多个类公开为 Restful 服务并映射到不同的路径。首先,我的配置中只有 cxf,我可以同时将所有类公开为服务。现在我也在使用 Camel ,我有这样的标签:

    <camelcxf:rsServer id="rsServer1" address="/"
            serviceClass="com.something.PoiSearchImpl">
        </camelcxf:rsServer>
 <camelcxf:rsServer id="rsServer2" address="/"
            serviceClass="com.something.FooBarImpl">
        </camelcxf:rsServer>

在此之后,我有两条路线从我的 cxf 端点(如上所述)开始并进行一些处理。问题是只有一个服务在工作,而其他服务只是没有被调用。它给了我 404 未找到错误。这是正常现象还是我的配置中缺少某些内容?

最佳答案

Hi Sikorski,
Camel supports multiple cxf:rsServer. The problem with your approach is that both are mapped to an address '/'. This means that one of the servers is invoked. 

Solution: You need to have unique address for each rsServer like below,

<camelcxf:rsServer id="rsServer1" address="/Bar" serviceClass="com.something.PoiSearchImpl">
</camelcxf:rsServer>
<camelcxf:rsServer id="rsServer2" address="/Foo" serviceClass="com.something.FooBarImpl">
</camelcxf:rsServer>

关于java - Apache Camel 和 CXF : Mutlitple cxf:rsServer tags . 。这可能吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10450606/

相关文章:

api - 当 URI 可以动态解析时,路由器有什么好处?

c# - 为什么 HttpWebRequest 抛出异常而不是返回 HttpStatusCode.NotFound?

jquery - $.getJSON 获取状态

javascript - 如何检测 iframe 中的 404 错误?

java - hibernate以主键作为外键的双向关联

java - OrientDB getVertices 不适用于 Java 生成的类/索引

java - MapReduce/Hadoop 入门

jquery - 在 Reactjs 中使用 RESTful 服务

c# - 如何在不缓冲的情况下流式传输来自 WCF 的响应?

java - infinispan 中的自定义哈希函数