Search code examples
web-servicesjaxbwebspherewsimport

JAXBWrapperException: JAXB object does not have a XXXX xml property


I get the following error:

[8/13/13 12:36:14:261 CAT] 00000024 SystemOut     O /com/acme/integration/Verify       Error calling VerifyService
  javax.xml.ws.WebServiceException: org.apache.axis2.jaxws.wrapper.impl.JAXBWrapperException: An internal assertion error occurred. The com.acme.services.VerifyFault JAXB object does not have a VerifyResult xml property.
    at org.apache.axis2.jaxws.wrapper.impl.JAXBWrapperToolImpl.unWrap(JAXBWrapperToolImpl.java:84)
    at org.apache.axis2.jaxws.marshaller.impl.alt.DocLitWrappedMethodMarshaller.demarshalResponse(DocLitWrappedMethodMarshaller.java:144)
    at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.createResponse(JAXWSProxyHandler.java:440)
    at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.invokeSEIMethod(JAXWSProxyHandler.java:351)
    at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.invoke(JAXWSProxyHandler.java:159)
    at $Proxy46.verify(Unknown Source)

A (cut down) extract of the wsdl:

        <xsd:element name="verify">
            <xsd:complexType>
                <xsd:sequence>
                    <xsd:element minOccurs="1" name="Type" type="xsd:int" />
                    <xsd:element minOccurs="1" name="Number" nillable="true" type="xsd:string" />
                </xsd:sequence>
            </xsd:complexType>
        </xsd:element>
        <xsd:element name="verifyResponse">
            <xsd:complexType>
                <xsd:sequence>
                    <xsd:element minOccurs="0" name="VerifyResult" type="xsd:int" />
                </xsd:sequence>
            </xsd:complexType>
        </xsd:element>
        <xsd:element name="verify_fault">
            <xsd:complexType>
                <xsd:sequence>
                    <xsd:element minOccurs="0" name="Code" nillable="true" type="xsd:string" />
                    <xsd:element minOccurs="0" name="Message" nillable="true" type="xsd:string" />
                </xsd:sequence>
            </xsd:complexType>
        </xsd:element>

The response I get from the service (in SOAPUI) that results in the error:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Body>
      <NS1:verify_fault xmlns:NS1="http://www.acme.com">
         <Code>RecordNotFound</Code>
         <Message>No Records Found.</Message>
      </NS1:verify_fault>
   </soapenv:Body>
</soapenv:Envelope>

Any help in understanding why I'm getting a JAXBWrapperException when, logically, there shouldn't be a VerifyResult node in the response would be appreciated.

I've tried renaming various elements using a bindings file as I believed the error to be related to an issue documented here but this turned out to be unrelated.


Solution

  • Turns out the 'fault' response was incorrect. It was missing the <soapEnv:Fault> element.

    The following response now returns the correct 'exception'.

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
       <soapenv:Body>
          <soapenv:Fault>
             <faultcode>soapenv:Server</faultcode>
             <faultstring>SOAP Fault Recieved from server.</faultstring>
             <detail>
                <NS1:verify_fault xmlns:NS1="https://www.acme.com">
                   <Code>RecordNotFound</Code>
                   <Message>No Records Found.</Message>
                </NS1:verifyCustomer_fault>
             </detail>
          </soapenv:Fault>
       </soapenv:Body>
    </soapenv:Envelope>