JAXBWrapperException:JAXB对象没有XXXX xml属性

时间:2013-08-13 14:56:11

标签: web-services jaxb websphere wsimport

我收到以下错误:

[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)

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>

我从服务(在SOAPUI中)获得的响应导致错误:

<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>

理解为什么我得到JAXBWrapperException的任何帮助,从逻辑上讲,响应中不应该有VerifyResult节点,我们将不胜感激。

我尝试使用绑定文件重命名各种元素,因为我认为错误与记录的问题有关here,但事实证明这是不相关的。

1 个答案:

答案 0 :(得分:1)

原来'错误'的反应不正确。它缺少<soapEnv:Fault>元素。

以下响应现在返回正确的“异常”。

<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>