2014-11-20 88 views
0

我有一個web應用程序。它有Servlets和JSP等,現在我添加一個Web服務。Spring和Camel CXF在WAR中很好玩

我可以得到CXF的工作。我的@WebService工作正常。

但我需要Web服務才能訪問我在Spring中設置的bean。

如果我嘗試添加以下內容,以便將請求轉發到EJB(因爲這樣的獨立應用程序工作正常):

<bean id="webServ" class="com.company.application.MyWebServiceHandler" /> 

<camelContext id="FindCode" xmlns="http://camel.apache.org/schema/spring"> 
    <route id="FindCodeRoute"> 
     <from uri="cxf:bean:myEndpoint?dataFormat=POJO" /> 
     <to uri="log:input?showAll=true&amp;level=INFO"/> 
     <to uri="bean:webServ?method=process" /> 
     <to uri="log:input?showAll=true&amp;level=INFO" /> 
    </route> 
</camelContext> 

它給了我「找不到任何從總線註冊HttpDestinationFactory。」 我已經Google了谷歌了。

我有

<import resource="classpath:META-INF/cxf/cxf.xml"/> 
<import resource="classpath:META-INF/cxf/cxf-extension-xml.xml"/> 
<import resource="classpath:META-INF/cxf/cxf-servlet.xml"/> 

,我已經試過進口

<dependency> 
     <groupId>org.apache.cxf</groupId> 
     <artifactId>cxf-rt-transports-http</artifactId> 
     <version>2.7.13</version> 
    </dependency> 

和/或 org.apache.cxf CXF-RT-運輸-HTTP-碼頭 2.7 .13

但是沒有。

有誰知道如何將EJB注入WebService?

如果我在@WebService上拍@ @Stateless,它找不到我注入的EJB。 NPE。我正在使用JBoss EAP 6.3。

回答

0

我用camel-example-cxf-tomcat作爲基礎解決了它。

+0

你應該解釋什麼是確切的解決方案,問題。還提供這個駱駝例子的鏈接。 – Sikorski 2014-11-24 09:28:30

+1

http://camel.apache.org/cxf-tomcat-example.html - 我不知道是什麼修復了它。我認爲問題是我有cxf:bean:handlerName而不是cxf:handlerName – djb 2014-11-24 11:26:02