javaosgicxfjbossfuse

CXF SOAP services retuning null as response


I am trying to unit test a piece of CXF soap service code. The code executes without any issue. But it returns null every time irrespective of what I am setting in body as a response.

public class MyRouteTest extends CamelTestSupport
{
private int port = AvailablePortFinder.getNextAvailable();
@Override
protected RouteBuilder createRouteBuilder() throws Exception {

    return new RouteBuilder() {

        @Override
        public void configure() throws Exception {

            JaxbDataFormat jaxb = new JaxbDataFormat();
            jaxb.setContextPath("com.example");

            from("cxf:http://localhost:"+port+"/test/OpenIssue?serviceClass="+OpenIssue.class.getCanonicalName())
            .convertBodyTo(OpenIssueRequest.class)
            .setBody(constant("OK"));
        }
    };
}

@Test
public void testMySoapRoute() {
    OpenIssueRequest request = new OpenIssueRequest();
    request.setXXX(270);
    request.setYYY("A");
    request.setZZZ("ABCD");
    String out = template.requestBody("cxf:http://localhost:"+port+"/test/OpenIssue?serviceClass="+OpenIssue.class.getCanonicalName(),request,String.class);
    assertNotNull(out);
}

}

This code should return "OK" as response but getting null


Solution

  • I was using camel-version 2.15.0.redhat-630329. I update it to camel-version of 2.17.0.redhat-630329. It got solved automatically.