I am trying to create a very simple service in JBoss Fuse for CXF-WS but I am having problem with the response message. The request is invoked correctly and the spring-camel route is working fine but the response always contains a blank 'SOAP Body' tag. Here is what I've done with the service :
- Create the java object model using wsdl2java.ext
- Exposed a CXF WS using camel
- Invoked a processor component in the camel route to create a response message. The message type of the is as expected by the interface as I created it using the generated object factory only.
Here is the camel route I have created :
<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>
Here is the 'getBookProcessor' component created for processing the response
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)));
}
}
Please let me know if I am missing anything here.