camel-cxf and spring DSL does not work very well
------------------------------------------------

                 Key: CAMEL-1431
                 URL: https://issues.apache.org/activemq/browse/CAMEL-1431
             Project: Apache Camel
          Issue Type: Sub-task
          Components: camel-cxf
    Affects Versions: 2.0-M1
            Reporter: Charles Moulliard


Hi,

Camel-cxf and camel works very well when the routing is defined like this :

public class ReportIncidentRoutes extends RouteBuilder {

    public void configure() throws Exception {
        // webservice response for OK
        OutputReportIncident OK = new OutputReportIncident();
        OK.setCode("0");

        // endpoint to our CXF webservice
        String cxfEndpoint = 
"cxf://http://localhost:8080/camel-example/incident";
                + 
"?serviceClass=org.apache.camel.example.reportincident.ReportIncidentEndpoint"
                + "&wsdlURL=wsdl/report_incident.wsdl";

        // first part from the webservice -> file backup
        from(cxfEndpoint)
            // we need to convert the CXF payload to InputReportIncident that 
FilenameGenerator and velocity expects
            .convertBodyTo(InputReportIncident.class)
            // return OK as response
            .transform(constant(OK));

    }

@ContextConfiguration
public class ReportIncidentRoutesTest extends AbstractJUnit4SpringContextTests  
{
        
        private static final transient Log LOG = 
LogFactory.getLog(ReportIncidentRoutesTest.class);
        
    @Autowired
    protected CamelContext camelContext;

    // should be the same address as we have in our route
    private final static String ADDRESS = 
"http://localhost:8080/camel-example/incident";;
    //private final static QName endpointName = new 
QName("http://reportincident.example.camel.apache.org";, 
"ReportIncidentEndpoint"); 

    protected static ReportIncidentEndpoint createCXFClient() {
        // we use CXF to create a client for us as its easier than JAXWS and 
works
        JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
        factory.setServiceClass(ReportIncidentEndpoint.class);
        factory.setAddress(ADDRESS);
        //factory.setEndpointName(endpointName);
        return (ReportIncidentEndpoint) factory.create();
    }

    @Test
    public void testRendportIncident() throws Exception {
        
        assertNotNull(camelContext);

        // create input parameter
        InputReportIncident input = new InputReportIncident();
        input.setIncidentId("123");
        input.setIncidentDate("2008-08-18");
        input.setGivenName("Claus");
        input.setFamilyName("Ibsen");
        input.setSummary("Bla");
        input.setDetails("Bla bla");
        input.setEmail("davscl...@apache.org");
        input.setPhone("0045 2962 7576");

        // create the webservice client and send the request
        ReportIncidentEndpoint client = createCXFClient();    
        OutputReportIncident out = client.reportIncident(input);

        // assert we got a OK back
        assertEquals("0", out.getCode());

    }
    

}


but not when the routing is defined in spring DSL

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans";
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
        xmlns:camel="http://camel.apache.org/schema/spring";
        xmlns:cxf="http://camel.apache.org/schema/cxf";
        xsi:schemaLocation=" http://www.springframework.org/schema/beans
                http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
                http://camel.apache.org/schema/osgi
                http://camel.apache.org/schema/osgi/camel-osgi.xsd
                http://camel.apache.org/schema/spring
                http://camel.apache.org/schema/spring/camel-spring.xsd
                http://camel.apache.org/schema/cxf
                http://camel.apache.org/schema/cxf/camel-cxf.xsd";>
                
    <bean id="webService" 
class="org.apache.camel.example.reportincident.beans.WebService" />
        
        <bean id="OK" 
class="org.apache.camel.example.reportincident.OutputReportIncident">
                <property name="code" value="0"/>
        </bean>
        
    <!-- webservice endpoint  -->          
    <cxf:cxfEndpoint id="reportIncident"
                     address="http://localhost:8080/camel-example/incident";
                     wsdlURL="wsdl/report_incident.wsdl"
                     
serviceClass="org.apache.camel.example.reportincident.ReportIncidentEndpoint"
                     xmlns:s="http://reportincident.example.camel.apache.org";>
    </cxf:cxfEndpoint>
     

        <camelContext trace="true" xmlns="http://camel.apache.org/schema/osgi";>
                
<camel:package>org.apache.camel.example.reportincident.routing</camel:package>
                
                <!-- CXF route -->
                <camel:route>
                        <camel:from uri="cxf:bean:reportIncident" />
                        <camel:convertBodyTo 
type="org.apache.camel.example.reportincident.InputReportIncident" />
                        <camel:transform>
                            <camel:method bean="OK" method="code"/>
                        </camel:transform>
                </camel:route>
                 
                 
        </camelContext>
</beans>

In debugging mode, I see that the outputreportincident object is null when we 
call the method declared in the web service. So something happens with Spring & 
Cxf.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to