I have a very simple camel route that makes soap to soap calls.
Everything work fine, but if one of the @Oneway operation throws SaopFault, I cannot catch the fault onException. How can I catch soapFault onException to set message to setBody(soapFault)?
Thank you for your help.
This method throws SaopFault from targetService
@WebMethod(operationName = "OneWayOperation")
@Oneway
public void onewayOperation(
@WebParam(partName = "OneWayOperationRequest",
name = "OneWayOperationRequest",
targetNamespace = "http://xxx.xxx.com/xmlschema/api")
com.xxx.xxx.xmlschema.api.OneWayOperationRequest oneWayOperationRequest
);
@Bean(name = "sourceBean")
public CxfEndpoint buildCxfSoapEndpoint() {
CxfEndpoint cxf = new CxfEndpoint();
cxf.setAddress("http://0.0.0.0:9090/api");
cxf.setServiceClass(com.xxx.Service.class);
cxf.setWsdlURL("wsdl/xxx.wsdl");
return cxf;
}
@Bean(name = "targetBean")
public CxfEndpoint buildCxfSoapEndpoint() {
CxfEndpoint cxf = new CxfEndpoint();
cxf.setAddress("https://xxxx.com:443/api");
cxf.setServiceClass(com.xxx.Service.class);
cxf.setWsdlURL("wsdl/xxx.wsdl");
return cxf;
}
from("cxf:bean:sourceBean")
.to("cxf:bean:targetBean")
.onException(SoapFault.class)
.process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
SoapFault fault = exchange.getProperty(ExchangePropertyKey.EXCEPTION_CAUGHT, SoapFault.class);
// ** OneWay methods never comes here but the others ! **
}
})
I've added ?dataFormat=MESSAGE and problem solved.
from("cxf:bean:sourceBean?dataFormat=MESSAGE")
.to("cxf:bean:targetBean?dataFormat=MESSAGE")