0
votes

I am very new to Apache CXF and I am stuck with the issue of removing namespace from the SOAP message that I receive from the external server (I am serving as a client for consuming the service)

The stubs that are generated from the wsdl have a different namespace in the @WebResult while the SOAP envelope which is received from the server system is different. I want to apply a generic solution so as to remove the namespace from the response message so the client validation does not fail.

o.a.c.p.PhaseInterceptorChain - Interceptor for {http://www.abc.xyz/webservices/facade}service#{http://www.abc.xyz/webservices/facade}serviceName has thrown exception, unwinding now

org.apache.cxf.interceptor.Fault: Unexpected element {http://www.abc.xyz/webservices/facade}serviceResponse found. Expected {http:// www.abc.xyz/webservices/facade/xxx}serviceResponse.

Kindly help.

Solutions tried till now :

(CXF Transformation Feature)

Map<String, String> inTransformMap = Collections.singletonMap("{http:// www.abc.xyz/webservices/facade/**xxx**}serviceResponse", "");
org.apache.cxf.interceptor.transform.TransformInInterceptor transformInInterceptor = new org.apache.cxf.interceptor.transform.TransformInInterceptor();
transformInInterceptor.setInTransformElements(inTransformMap);
proxy.getInInterceptors().add(transformInInterceptor);

In this approach, when I try to replace {http://www.abc.xyz/webservices/facade/**xxx**}serviceResponse with "", server hangs and it goes into infinite loop at org.apache.cxf.staxutils.transform.InTransformReader.handleDeepDrop() line 266

1
Welcome to Stack Overflow! We are a question-and-answer site, not a coders-for-hire service. Please explain what you have tried so far and why it hasn't worked. See: Why is "Can someone help me?" not an actual question?Joe C

1 Answers

0
votes

I was finally able to solve this issue by the following

JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
Map<String, Object> props = factory.getProperties();
if (null == props) {
    props = new HashMap<String, Object>();
}
props.put("soap.no.validate.parts", true);
factory.setProperties(props);

The above solution will allow the incoming response validation to be turned off and hence there won't be any exception like org.apache.cxf.interceptor.Fault: Unexpected element.