4

问题描述: 我无法从我的 camel servlet 路由到 cxfbean。路由初始化失败并显示以下错误消息:

"Failed to create route route1 at: >>> To[cxfbean:fooEndpoint] <<< in route:
 Route[[From[servlet:///?servletName=BwsServlet]] -> [To[cxfb... because of Failed to resolve 
 endpoint: cxfbean://fooEndpoint due to: null".

没有 cxfbean 的 servlet 可以正常启动。

更新:请注意,我打算使用Camel Cxf Bean 组件,而不是Camel Cxf Bean

我想要实现的目标: 我在 Tomcat 中运行一个骆驼 servlet。我有一个实现我的 web 服务接口的 bean(由 CXF 从 WSDL 生成)。我想在将 XML 消息体传递给这个 webservice bean 之前对其进行处理。我想使用 cxf bean 组件而不是 cxf 端点 bean,因为除了已经运行的骆驼 servlet 之外,我不想让我的 cxf 端点在网络端口上监听。

我的代码是什么样子的: 我的 camel-config.xml 看起来像这样:

<bean id="bwsRouteBuilder" class="local.com.foo.BwsRouteBuilder"/>
<bean id="fooEndpoint" class="local.com.foo.FooBws"/>
<camel:camelContext id="bws">
    <camel:routeBuilder ref="bwsRouteBuilder"/>
</camel:camelContext>

我的路由构建器(用 Java DSL 编写)如下所示:

public void configure() throws Exception {
    from("servlet:///?servletName=BwsServlet")
    // some processing of message here
    .to("cxfbean:fooEndpoint");
}

更新:注意上面代码中定义的 cxfbean URI格式

我的 web.xml 看起来像这样:

<servlet>
    <servlet-name>BwsServlet</servlet-name>
    <servlet-class>org.apache.camel.component.servlet.CamelHttpTransportServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>BwsServlet</servlet-name>
    <url-pattern>/*</url-pattern>
</servlet-mapping>

camel-cxf 作为依赖项包含在我的 pom.xml 中。

到目前为止我在哪里寻求帮助:我正在关注Apache Camel cxfbean 描述中的文档,并关注了 stackoverflow。我希望我的问题不是很容易回答,我是骆驼的新手。

非常感谢您的想法

4

1 回答 1

-1

如果你想使用 cxf bean,你必须在你的路由中写“cxf:bean:fooEndpoint”(你忘记了:在 cxf 和 bean 之间)。

public void configure() throws Exception {
    from("servlet:///?servletName=BwsServlet")
    // some processing of message here
    .to("cxf:bean:fooEndpoint");
}
于 2012-08-28T05:59:02.040 回答