Although I've interacted with them for years I'm very new to WSDL design. I have a WSDL that I'm trying to use with Camel & CXF generating the code using wsdl2java.
What I'm trying to achieve is a custom response string to the SOAP client and convert the SOAP request to JSON and push it to a websockets endpoint.
My WSDL schema generates the response classes when the code is generated, but the response never seems to be called in the debugger.
Whats more, if I remove the json converter in Camel the whole soap request is returned to the SOAP client, if I leave my converter in, it then gets upset because its expecting XML and it gets a json blob.
<cxf:cxfEndpoint id="position-ws"
address="/positions"
endpointName="c:PositionsPort"
serviceName="c:PositionsService"
serviceClass="com.company.finance.positions.PositionsImpl"
xmlns:c="http://positions.finance.company.com/">
<cxf:properties>
<entry key="schema-validation-enabled" value="true"></entry>
</cxf:properties>
</cxf:cxfEndpoint>
<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
<dataFormats>
<xmljson id="xmljson"/>
<xmljson id="xmljsonWithOptions" forceTopLevelObject="true" trimSpaces="true" rootName="newRoot" skipNamespaces="true"
removeNamespacePrefixes="true" expandableProperties="d e"/>
</dataFormats>
<route>
<from uri="cxf:bean:position-ws?dataFormat=PAYLOAD"/>
<convertBodyTo type="String"></convertBodyTo>
<to uri="log:com.mycompany.order?level=DEBUG"/>
<process ref="xmlTransformProcessor"/>
<to uri="log:com.mycompany.order?level=DEBUG"/>
<to uri="websocket:positionsTopic?sendToAll=true"/>
</route>
</camelContext>
<bean id="xmlTransformProcessor" class="com.company.finance.positions.XMLTransformer"/>
XML to Json Converter
public class XMLTransformer implements Processor {
public void process(Exchange exchange) throws Exception {
String data = exchange.getIn().getBody(String.class);
JSONObject jsonObj = XML.toJSONObject(data);
String json = jsonObj.toString();
// use regular java code to transform to a better form
//exchange.getIn().setBody(json);
exchange.getOut().setBody(json);
}
}
So my question is, using Camel, how do I return a custom response String "Okay", "Not Okay" etc whilst pushing the rest of the data to another step in the route?
Thanks