我一直在用cxf和camel制作宁静的Web服务,遇到一个奇怪的问题,我不知道这是正常的骆驼行为还是什么。

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

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


在这之后,我有两条路由从我的cxf端点(如上所述)开始并进行一些处理。问题仅是其中一项服务正在运行,而另一项则没有被调用。它给了我404 not found错误。这是正常现象还是我的配置中缺少什么?

最佳答案

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>

10-05 21:30