Why does cxf throw an unmarshalling error on elements that have no namespace prefix when the namespace should be inherited

456 views Asked by At

I am creating a SOAP client that runs in a Java 11 Spring Boot server and makes requests to a Java 8 server. I'm using cxf-rt-frontend-jaxws:3.4.3 and cxf-rt-transports:3.4.3 in a Gradle 6.9 build with the com.github.bjornvester.wsdl2java Gradle plugin version 1.1.

My client can call a simple echo test SOAP operation with no problem. That service passes a request object containing a single String and gets a response object containing the String. So I know the basic connection is working and the other end is responding.

My problem arises when I call an operation that has no input and returns a list of objects in the response. I get this error:

org.apache.cxf.interceptor.Fault: Unmarshalling Error: unexpected element (uri:"", local:"ProposalInfo"). Expected elements are <{http://V2.pub.proposal.server.ws.cayuse.com/}ProposalInfo>

I am told that other systems call these operations with no problem.

I have stepped through the cxf and JAXB code and notice that the IntelliJ shows this text associated with a BranchingReaderSource. Not sure if this is a true error or just a side-effect of the debugger trying to call toString() on this class (which has no such method).

Method threw 'java.lang.NullPointerException' exception. Cannot evaluate com.ctc.wstx.io.BranchingReaderSource.toString()

I also notice that a class called ValidationEventLocatorImpl gets a NullPointerException on this line because "toURL" is null. I think this is because toURL comes from the empty prefix of in the response.

this.url = toURL(loc.getSystemId());

I have tried using wrapping-style "false" but that does not change anything.

I also tried to use TransformInInterceptor to map elements with no prefix to the desired prefix, but that did not work. It seems the unmarshalling error gets thrown before the interceptor runs.

Here is the WSDL used for this service; the operation that I am calling is getUnpairedProposals. I also attach a copy of the response to this operation -- the operation that is not getting unmarshalled properly. My reading of this response is that the namespace defined on the ns2:getUnPairedProposalsResponse tag should apply to the child elements such as .

Additional info:

I made several attempts to use TransformInterceptor to map the elements:

  1. Added a map entry for "getUnPairedProposalsResponse -> {http://V2.pub.proposal.server.ws.cayuse.com/}getUnPairedProposalsResponse". This did nothing.

  2. Inserted the TransformInterceptor at Phase.PRE_STREAM. Also had no effect.

  3. Changed the mapping from #1 to the same but added a prefix {}, as in {}getUnPairedProposalsResponse -> {http://V2.pub.proposal.server.ws.cayuse.com/}getUnPairedProposalsResponse. This got me a null pointer exception in cxf at TransformUtils line 128 in the convertToQnamesMap method.

0

There are 0 answers