0
votes

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 :

  1. Create the java object model using wsdl2java.ext
  2. Exposed a CXF WS using camel
  3. 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.

1
Finally this one is fixed, unfortunately the version of 'cxf-rt-transports-http-jetty' was not compatible with my version of camel-cxf. once I updated the same it started working. Here is the working configuration I have - Gaurav Sharma

1 Answers

0
votes

Finally this one is fixed, unfortunately the version of 'cxf-rt-transports-http-jetty' was not compatible with my version of camel-cxf. once I updated the same it started working. Here is the working configuration I have

   <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>