0

我对带有骆驼路由文件的 cxf 休息 Web 服务的行为感到困惑。我注意到控件永远不会进入其余服务接口的实现类。

以下是我如何使用 cxf jaxrs 和骆驼编写 Web 服务的步骤

  1. 我已经创建了一个界面。

    @Path("/licence")
    public interface LicenceThresholdService {
        @POST
        @Consumes({MediaType.APPLICATION_JSON})
        @Path("/userThresholdBreached")
        Boolean isUsersThresholdBreached(User user);
    }
    
  2. 实现类

    public class LicenceThresholdServiceImpl implements LicenceThresholdService {
        @Override
        public Boolean isUsersThresholdBreached(final OEMUser user) {
            System.out.println("inside threshold breched method");
            return Boolean.FALSE;
        }
     }
    
  3. 创建 cxf jaxrs 服务器

    <beans ...
        xmlns:cxf="http://camel.apache.org/schema/cxf"
        ...
        xsi:schemaLocation="
         http://camel.apache.org/schema/cxf 
         http://camel.apache.org/schema/cxf/camel-cxf.xsd
        ...">
        <cxf:rsServer id="userProfileService"
            address="http://{{service.host}}:{{service.port}}/userProfile"
            serviceClass="com.jato.esb.service.licence.LicenceThresholdServiceImpl"
            loggingFeatureEnabled="true">
            <cxf:providers>
                <bean class="org.codehaus.jackson.jaxrs.JacksonJsonProvider"/>
            </cxf:providers>
        </cxf:rsServer>
    </beans>
    
  4. 在骆驼路由端点中注入了 cxf rsServer bean

    <from uri="cxfrs://bean://userProfileService" />
    

现在我的问题是,每当我调用此服务时,控制都不会进入类isUsersThresholdBreached的方法中LicenceThresholdServiceImpl。因此,我无法充分利用 cxf 休息服务。

我已经使用 Mule esb 和 Spring 应用程序文件尝试了 cxf 休息服务,我注意到控制也总是在实现类中,但骆驼路线并非如此。我正在使用redhat fuse esb。

请帮我解决这个问题,这是我们与骆驼一起去的一个严重问题。

4

1 回答 1

0

您使用的serviceClass只是将REST请求映射到java方法调用,调用信息将传递到camel route。这样我们可以提供更通用的解决方案,你可以不需要使用ProducerTemplate发送消息到camel路由。

于 2014-04-04T06:15:26.540 回答