I am making a call to an external webservice and the faultcode that is returned seems to be causing some trouble for CXF. The response is as follows :
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><soap:Fault><faultcode>S:Server</faultcode><faultstring>Something serious wen wrong</faultstring></soap:Fault></soap:Body></soap:Envelope>
CXF has trouble with this because of the S:Server not being valid. The resulting error is
java.lang.RuntimeException: Invalid QName in mapping: S:Server
I am trying to use the CXF Transform feature to change the faultcode but I cannot seem to get it working correctly. The desired output should be:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><soap:Fault><faultcode>soap:Server</faultcode><faultstring>Something serious wen wrong</faultstring></soap:Fault></soap:Body></soap:Envelope>
I have had a look at CXF Transform Feature and tried the following in my code :
BindingProvider bp = (BindingProvider) port;
bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointURL);
Client client = ClientProxy.getClient(port);
Map<String, String> inTransformMap = Collections.singletonMap("faultcode", "faultcode=soap:Server");
org.apache.cxf.feature.StaxTransformFeature staxTransformFeature = new org.apache.cxf.feature.StaxTransformFeature();
staxTransformFeature.setInAppendElements(inTransformMap);
staxTransformFeature.initialize(client, client.getBus());
This does not seem to replace the faultcode. I have also tried other variations like
- staxTransformFeature.setInTransformElements(inTransformMap)
- inTransformMap = Collections.singletonMap("{}faultcode", "{}faultcode=soap:Server"); but with no luck.
I am unable to find any clear examples showing the usage of the transform feature (eg. input and output xml)
Please guide me on what I may be doing wrong.
Thanks in advance.