I'm facing an issue converting my SOAP request from CXF payload format to required format.
This is what the request looks like:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header/>
<soapenv:Body>
<ObscureSOAPOperation xmlns="<wsdl-namespace-url>">
<ObjectInfo>
<value1>value1</value1>
<value2>value2</value2>
</ObjectInfo>
</ObscureSOAPOperation>
</soapenv:Body>
</soapenv:Envelope>
And this is what my route looks like:
from("properties:soapoperation.service.cxf.endpoint")
.to("log:info?showAll=true")
.process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
CxfPayload<?> request = (CxfPayload<?>) exchange.getIn().getBody();
Source source = request.getBodySources().get(0);
JAXBElement<ObjectInfo> objectInfoElement =
jaxbContext.createUnmarshaller().unmarshal(source, ObjectInfo.class);
System.out.println("~~~~~~~~~Object Info value1: " + objectInfoElement.getValue().getValue1() + "~~~~~~~~~");
}
})
ObjectInfo
is WSDL generated class. Incidentally the WSDL is a rpc/literal style wsdl.
The issue is that when the request from exchange is being cast to CxfPayload. It becomes null. The DOMSource looks like:
<ObjectInfo>
<value1>null</value1>
<value2>null</value2>
</ObjectInfo>
My SOAP request actually contains couple of more elements after ObjectInfo
(the WSDL has multi-part message for the particular SOAP request) which are also null.