javax.xml.bind.UnmarshalException:零长度 BigInteger - 链接异常:[java.lang.NumberFormatException:零长度 BigInteger

javax.xml.bind.UnmarshalException: Zero length BigInteger - with linked exception: [java.lang.NumberFormatException: Zero length BigInteger

当我在 axis2 环境中验证 WSDL 中的整数字段时,出现以下错误。这适用于 xml 个 bean。但是我在使用 xjc beans 对象时遇到错误。 XSD 验证失败!!!当我传递空值时出现此错误。

请帮我解决这个问题。

 <xsd:element minOccurs="0" name="TypeName" type="types:PrincipalVariantType"/>
 <xsd:simpleType name="PrincipalVariantType">
    <xsd:restriction base="xsd:integer">
        <xsd:enumeration value="1" />
        <xsd:enumeration value="2" />
        <xsd:enumeration value="3" />
        <xsd:enumeration value="4" />
    </xsd:restriction>
  </xsd:simpleType>

堆栈跟踪

原样

<xsd:simpleType name="PrincipalVariantType">
   <xsd:restriction base="xsd:integer">
       <xsd:enumeration value="1" />
       <xsd:enumeration value="2" />
       <xsd:enumeration value="3" />
       <xsd:enumeration value="4" />
   </xsd:restriction>
</xsd:simpleType>

在这种情况下仅有效 <TypeName>1</TypeName><TypeName>2</TypeName><TypeName>3</TypeName><TypeName>4</TypeName>

注意:空值不是数字,不允许为整数。

如果你想在 xsd:string 中更改类型并在

中更改限制
<xsd:simpleType name="PrincipalVariantType">
    <xsd:restriction base="xsd:integer">
        <xsd:pattern value="[1-4\n]|()"/>
    </xsd:restriction>
</xsd:simpleType>

这对我来说也很好用。

<xsd:restriction base="xsd:string">
                <xsd:pattern value="(\s*[1-4\n]\s*)+"/>
</xsd:restriction>