2015-11-20 33 views
2

所有的骆驼运行CXF-RS服务器(与蓝图)的例子骆驼CXF RS服务器,如下所示:嵌入WAR

<cxf:rsServer id="rsServer" address="http://localhost:8000/CxfRsRouterTest/route" 
     serviceClass="org.apache.camel.component.cxf.jaxrs.testbean.CustomerService" > 

    ... 
    </cxf:rsServer> 

然后

<route id="control"> 
     <from uri="cxfrs://bean://rsServer"/> 
     <log message="test..."/> 
</route> 

但这在Camel在WAR中运行时没有意义,因为address不能是任意的,而是在主机应用程序的上下文中。 (?此外,如何设置URL中的全名在这里不断有意义难道不应该是唯一的港口和路径?)

我想什么是以下内容添加到web.xml中:

<!-- CXF servlet --> 
    <servlet> 
    <servlet-name>CXFServlet</servlet-name> 
    <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class> 
    <load-on-startup>1</load-on-startup> 
    </servlet> 

    <servlet-mapping> 
    <servlet-name>CXFServlet</servlet-name> 
    <url-pattern>/*</url-pattern> 
    </servlet-mapping> 

在这种情况下,当我打http://localhost:8080/myapp/route我得到:

org.apache.cxf.transport.servlet.ServletController调用警告:

无法˚F ind对localhost的请求:8080/myapp/route的Observer

是否支持此方案?如果有,如何配置?

+0

<cxf:rsServer id="rsServer" address="/CxfRsRouterTest/route" serviceClass="org.apache.camel.component.cxf.jaxrs.testbean.CustomerService" > 

给予接入为什么/ MYAPP /路由,而不是仅仅/路线? – ash

+0

因为应用程序的上下文是myapp。 – kaqqao

+0

定义在哪里? – ash

回答

1

下面应该工作:在

http://localhost:8080/CxfRsRouterTest/route 
+0

这工程!只需确保CXFServlet也在监听相同的URL模式。但是...我没有得到: org.apache.cxf.transport.servlet.ServletController invoke 警告:无法找到http:// localhost:8080/myapp/route的观察者的请求 – kaqqao

+0

我认为实际上您的应用程序中可能会运行多个网络服务器。这是通过tomcat启动的吗?骆驼CXF启动自己的嵌入式Web服务器。 – ash

+0

整个事情现在在Jetty上运行。在我的web.xml中,我配置了一个CXFServlet并将其映射到/ *上。也许这不是要走的路?我的骆驼路线如上所述。我希望Camel尽可能使用主机应用程序服务器,而不是自己启动。 – kaqqao