2015-11-26 71 views
0

我想在JBoss Fuse中爲CXF-WS創建一個非常簡單的服務,但我遇到了響應消息的問題。該請求被正確調用,並且spring-camel路由工作正常,但響應始終包含空白的「SOAP Body」標籤。以下是我的服務進行:Jboss Fuse CXF請求/響應

  1. 使用wsdl2java.ext
  2. 露出了CXF WS使用駱駝
  3. 調用的處理器組件在駱駝路線創建響應創建Java對象模型信息。該接口的消息類型與接口所期望的一樣,正如我僅使用生成的對象工廠創建的那樣。

這裏是我創建的駱駝路線:

<camelContext xmlns="http://camel.apache.org/schema/spring" > 

    <!-- Define the CXF End-point --> 
    <endpoint id="bookMartEndpoint" uri="cxf:http://localhost:8200/OnlineBookMart"> 
     <property key="serviceClass" value="org.jbossfusesamples.bookmart.BookMart" /> 
    </endpoint> 

    <!-- Define the entity for bookmart set Query --> 
    <endpoint uri="sql:select * from bookmart" id="getBookQuery" > 
     <property key="dataSource" value="datasourceBean"/> 
    </endpoint>  

    <!-- Define the camel route --> 
    <route id="WSGateway" > 
     <from ref="bookMartEndpoint" /> 
     <recipientList> 
      <simple>direct:${header.operationName}</simple> 
     </recipientList>   
    </route> 

    <!-- Implement the getBook operation --> 
    <route id="getBookRoute" > 
     <from uri="direct:getBook"/> 
     <log message="Route : direct -> getBook" /> 
     <process ref="getBookProcessor" /> 
     <log message="${body}" /> 
    </route> 

</camelContext> 

這裏是處理響應創建「getBookProcessor」組件

public class getBookProcessor implements Processor { 

    //create a logger instance 
    private static final Logger LOG = LoggerFactory.getLogger(getBookProcessor.class); 

    @Override 
    public void process(Exchange exchange) throws Exception { 

     LOG.info("Processing getBook interface");  

     //create a response element 
     BookType response = new BookType(); 
     response.setAuthor("Dummy"); 
     response.setTitle("Dummy"); 
     response.setIsbn("Dummy"); 

     org.jbossfusesamples.book.ObjectFactory oFactory = new ObjectFactory(); 

     //create the response object from the object factory 
     exchange.getOut().setBody((oFactory.createGetBookResponse(response))); 
    } 
} 

請讓我知道如果我錯過什麼這裏。

+0

最後這一個是固定的,不幸的「CXF-RT-運輸-HTTP-碼頭」的版本不符合我的版本駱駝CXF的兼容。一旦我更新了它,它開始工作。這是我的工作配置 –

回答

0

最後這個是固定的,不幸的是'cxf-rt-transports-http-jetty'的版本與我的camel-cxf版本不兼容。一旦我更新了它,它開始工作。這裏是工作的配置我有

<dependency> 
     <groupId>org.apache.camel</groupId> 
     <artifactId>camel-cxf</artifactId> 
     <version>2.15.1.redhat-620133</version> 
    </dependency> 
    <dependency> 
     <groupId>org.apache.cxf</groupId> 
     <artifactId>cxf-rt-transports-http-jetty</artifactId> 
     <version> 3.0.6</version> 
    </dependency>