0

I'm facing the following error:

org.apache.cxf.interceptor.Fault: Unmarshalling Error: 
unexpected element (uri:"URL1", local:"cdrNummer")
Expected elements are <{URL2}cdrNummer>,<{URL2}meldingen>,<{URL2}akteafschrift> 
at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:932) ~[cxf-rt-databinding-jaxb-3.3.5.jar:3.3.5]
at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:738) ~[cxf-rt-databinding-jaxb-3.3.5.jar:3.3.5]
at org.apache.cxf.jaxb.io.DataReaderImpl.read(DataReaderImpl.java:170) ~[cxf-rt-databinding-jaxb-3.3.5.jar:3.3.5]

Setup using stub service running locally, which returns data. Using apache.cxf version 3.3.5.

When I hit that service for the first 6 times - it fails with above error even though I see successful response (SOAP envelope) in the logs. Hitting service for the 7th time returns a successful response "Without" throwing the above error and then things work fine until I restart the application.

I have verified the schema definition and it seems correct:

<xs:complexType name="opvragenAkteafschriftAntwoord">
    <xs:sequence>
        <xs:element name="cdrNummer" type="types:cdrNummer">
          <xs:annotation>
            <xs:documentation>useful</xs:documentation>
          </xs:annotation>
        </xs:element>
        <xs:element minOccurs="0" name="akteafschrift" type="types:akteafschrift"/>
        <xs:element minOccurs="0" name="meldingen" type="types:meldingen"/>
    </xs:sequence>
</xs:complexType>

First argument cdrNummer is mandatory, where as the other two are optional. Also tried to supply the other two optional arguments, then also just URL value changes, but I get the same unmarshalling error.

Bogdan
  • 23,890
  • 3
  • 69
  • 61
Manan
  • 140
  • 2
  • 14
  • You say, *I see successful response (SOAP envelope) in the logs*. Does this response contain a valid response or is it a SOAP Fault? Also, has the WSDL changed since you generated the service stub, or how did you generate the stub? Also, how are you making the call? – Bogdan Feb 27 '21 at 11:34
  • Yes - Its a valid response. There is no change in WSDL. Call is via postman or sprintboot application - result is same either way. – Manan Feb 27 '21 at 12:06
  • Any difference between the first 6 SOAP requests and the 7th? Or are they identical? Also, could you try with another version of apache cxf? 3.3.8 and 3.3.9 seem available. – Bogdan Feb 27 '21 at 12:16
  • There is no difference in each request as I have request ready in postman/spring application and verified that its sending exactly same parameters. Let me try with different version of cxf - Its a good point - I will post the result once I perform it. – Manan Feb 27 '21 at 14:13
  • @Bogdan Tried with different version - still behaviour is same. – Manan Feb 27 '21 at 14:36
  • That's weird. You shouldn't be getting unmarshalling errors unless the stub and the wsdl don't match, or if the SOAP messages are wrongly formatted. There is also URL1 and URL2 in the message, which again points to a mismatch. If you feed the WSDL to [SoapUI](https://soapui.org/downloads/soapui/) and use it to call the service, do you get the same result? – Bogdan Feb 27 '21 at 17:51
  • I tried feeding WSDL to SOAPUI - made a call, it works seamlessly. Response also exactly matching with what I receive in application/postman call. I am not clear on how URL1 and URL2 mapped, what I observed is URL1 do not contain namespace prefix where as URL2 contains namespace prefix ns2. Additionally I observed that - if I modified stub response with 2 optional fields then it started working, but not clear on why such behaviour. For which I am digging jaxb implementation specifically JAXBEncoderDecoder and Loader (Method: reportUnexpectedChildElement) – Manan Feb 28 '21 at 06:28

0 Answers0