0
votes

I have a simple Camel Route which takes an incoming message then calls processor which changes to body to a Java object and send it back out to client via CXF-SOAP.

Route is below:

@Component
public class DcToAspResponseRoute extends AspRouteBuilder {

  @Autowired
  DcToAspResponseProcessor processor;

  @Override
  public void configure() throws Exception {
    final RouteDefinition routeDefinition = createRouteDefinition("{{asp.generic.route}}",
        RouteId.DC_TO_ASP_RESPONSE_ROUTE.getRouteId());

    routeDefinition
      .process(processor)
  }
}

The processor is below:

@Component
public class DcToAspResponseProcessor implements Processor {
  @Autowired
  // protected for unit testing
  protected ObjectFactory objectFactory;

  @Override
  public void process(Exchange exchange) throws Exception {
    Response response = objectFactory.createResponse();
    response.setResponse(ResponseType.SUCCESS);

    exchange.getIn().setBody(response, Response.class);
  }
}

My problem occurs on line:

exchange.getIn().setBody(response, Response.class);

When I try to set the POJO Java object instantiated above onto the body rather than setting it as a Java POJO object onto exchange body the POJO get transformed into it XML form as below:

Exchange[Message: <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Response xmlns="http://xxx.yyy.zzz/2008">
    <response>Success</response>
</Response>
]

Due to this conversion I believe when CXF tries to marshall out a SOAP Response from the exchange it realises this is an "invalid" body and disregards it thus given me back below empty body SOAP response instead of populated response:

    <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
   <soap:Body/>
</soap:Envelope>

Can anyone help me out? I'm lost for ideas! Any help is highly-appreciated.

1

1 Answers

0
votes

Hopefully this will help anyone in the future...As it turns out its was a bug causing this behavior downgraded to CXF-v3.1.0 and now it works as it should.