XSD:不期望元素'AdditionalData'

时间:2018-05-18 06:07:41

标签: java xml xsd wsdl xsd-validation

我正面临XSD验证问题,因为我发送的请求似乎与xsd架构不兼容。 一直在研究它,但无法找到会导致这种问题的原因。

我得到以下异常:

Caused By: oracle.xml.parser.v2.XMLParseException; lineNumber: 0; columnNumber: 0; Element 'AdditionalData' not expected.
        at oracle.xml.parser.v2.XMLError.flushErrors(XMLError.java:274)
        at oracle.xml.parser.v2.XMLElement.validateContent(XMLElement.java:3260)
        at oracle.xml.parser.v2.XMLElement.validateContent(XMLElement.java:3171)
        at oracle.integration.platform.blocks.mesh.MeshImpl.validateXML(MeshImpl

以下是UserData xsd架构。这里出现元素'AdditionalData',导致上述异常。 关闭验证后,我的用例工作正常。

<?xml version="1.0" encoding="UTF-8" ?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified"
           targetNamespace="http://xmlns.myapp.com/UserMngtApp/UserSrvc/UserData"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns="http://xmlns.myapp.com/UserMngtApp/UserSrvc/UserData"
           xmlns:general="http://xmlns.myapp.com/UserMngtApp/UserSrvc/GeneralData"
           xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
           xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" jaxb:version="1.0"
           jaxb:extensionBindingPrefixes="xjc">
    <xs:annotation>
        <xs:appinfo>
            <jaxb:schemaBindings>
                <jaxb:package name="myapp.main.requestdataws.webservicestubs.types"/>
            </jaxb:schemaBindings>
        </xs:appinfo>
    </xs:annotation>
    <xs:import namespace="http://xmlns.myapp.com/UserMngtApp/UserSrvc/GeneralData"
               schemaLocation="GeneralRequestData.xsd"/>
    <xs:element name="UserId" type="xs:string"/>
    <xs:element name="UserData" type="UserDataType"/>
    <xs:complexType name="UserDataType">
        <xs:sequence>
            <xs:element name="usr_key" type="general:MultiValueType"
                        nillable="true"/>
            <xs:element name="act_key" type="general:MultiValueType"
                        nillable="true"/>
            <xs:element name="LastName" type="general:MultiValueType"
                        nillable="true"/>
            <xs:element name="FirstName" type="general:MultiValueType"
                        nillable="true"/>
            <xs:element name="MiddleName" type="general:MultiValueType"
                        nillable="true"/>
            <!-- <xs:element name="FullName" type="general:MultiValueType"/> -->
            <xs:element name="DisplayName" type="general:MapValueType"
                        nillable="true"/>
            <xs:element name="XellerateType" type="general:MultiValueType"
                        nillable="true"/>
            <xs:element name="Status" type="general:MultiValueType"
                        nillable="true"/>
            <xs:element name="Role" type="general:MultiValueType"
                        nillable="true"/>
            <xs:element name="UserLogin" type="general:MultiValueType"
                        nillable="true"/>
            <xs:element name="FullName" type="general:MapValueType"
                        nillable="true"/>
            <xs:element name="UserManagerKey" type="general:MultiValueType"/>
            <xs:element name="AdditionalData"
            type="general:AdditionalDataType" maxOccurs="1000"
            nillable="true"/>
        </xs:sequence>
    </xs:complexType>
</xs:schema>

是UserData引用的另一个架构:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://xmlns.myapp.com/UserMngtApp/UserSrvc/GeneralData" 
        xmlns:xs="http://www.w3.org/2001/XMLSchema"  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.myapp.com/UserMngtApp/UserSrvc/GeneralData" 
     xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
     xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" jaxb:version="1.0" jaxb:extensionBindingPrefixes="xjc">
    <xs:annotation>
        <xs:appinfo>
            <jaxb:schemaBindings>
                <jaxb:package name="myapp.main.requestdataws.webservicestubs.types"/>
            </jaxb:schemaBindings>
        </xs:appinfo>
    </xs:annotation>



    <xs:complexType name="MultiValueType">
        <xs:sequence>
            <xs:element name="Value" type="xs:string" minOccurs="0" maxOccurs="1000" nillable="true"/>
        </xs:sequence>
    </xs:complexType>

     <xs:complexType name="AdditionalDataType">
        <xs:sequence>
            <xs:element name="Value" type="xs:string" minOccurs="0" maxOccurs="1000" nillable="true"/>
        </xs:sequence>
        <xs:attribute name="Name" type="xs:string"/>
    </xs:complexType>


    <xs:complexType name="MapValueType">
        <xs:sequence>
            <xs:element name="Key" minOccurs="0" maxOccurs="1000" nillable="true">
                <xs:complexType>
                    <xs:attribute name="Name" type="xs:string"/>
                    <xs:attribute name="Value" type="xs:string"/>
                </xs:complexType>
            </xs:element>
        </xs:sequence>  
    </xs:complexType>   

</xs:schema>

以下是因上述异常而失败的请求。

<?xml version="1.0" encoding="UTF-8"?><messages>
<beneficiaryUserKey>
      <part xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="UserId">
         <UserId xmlns="http://xmlns.myapp.com/UserMngtApp/UserSrvc/UserData">6</UserId>
      </part>
   </beneficiaryUserKey>
<beneficiaryUserDetails>
      <part xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="UserData">
         <ns8:UserData xmlns:ns8="http://xmlns.myapp.com/UserMngtApp/UserSrvc/UserData" xmlns="http://xmlns.myapp.com/UserMngtApp/UserSrvc/RequestData" xmlns:ns0="http://xmlns.myapp.com/UserMngtApp/UserSrvc/AccountData" xmlns:ns9="http://xmlns.myapp.com/UserMngtApp/UserSrvc/GeneralData" xmlns:ns3="http://xmlns.myapp.com/UserMngtApp/UserSrvc/EntitlementData" xmlns:ns1="http://xmlns.myapp.com/UserMngtApp/UserSrvc/AppInstanceData" xmlns:ns6="http://xmlns.myapp.com/UserMngtApp/UserSrvc/ResourceData" xmlns:ns2="http://xmlns.myapp.com/UserMngtApp/UserSrvc/CatalogData" xmlns:ns4="http://xmlns.myapp.com/UserMngtApp/UserSrvc/FaultData" xmlns:ns5="http://xmlns.myapp.com/UserMngtApp/UserSrvc/OrgData" xmlns:ns7="http://xmlns.myapp.com/UserMngtApp/UserSrvc/RoleData" xmlns:wsa="http://www.w3.org/2005/08/addressing">
            <ns8:usr_key>
               <ns9:Value>6</ns9:Value>
            </ns8:usr_key>
            <ns8:act_key>
               <ns9:Value>1</ns9:Value>
            </ns8:act_key>
            <ns8:LastName>
               <ns9:Value>User_1526622550960</ns9:Value>
            </ns8:LastName>
            <ns8:FirstName>
               <ns9:Value>User_1526622550960</ns9:Value>
            </ns8:FirstName>
            <ns8:MiddleName>
               <ns9:Value>User_1526622550960</ns9:Value>
            </ns8:MiddleName>
            <ns8:DisplayName>
               <ns9:Key Name="base" Value="User_1526622550960 User_1526622550960 User_1526622550960"/>
            </ns8:DisplayName>
            <ns8:XellerateType xsi:nil="true"/>
            <ns8:Status>
               <ns9:Value>Active</ns9:Value>
            </ns8:Status>
            <ns8:Role>
               <ns9:Value>Full-Time</ns9:Value>
            </ns8:Role>
            <ns8:UserLogin>
               <ns9:Value>USER_1526622550960</ns9:Value>
            </ns8:UserLogin>
            <ns8:FullName xsi:nil="true"/>
            <ns8:UserManagerKey>
               <ns9:Value>5</ns9:Value>
            </ns8:UserManagerKey>
            <ns8:AdditionalData Name="Common Name">
               <ns9:Value>User_1526622550960</ns9:Value>
            </ns8:AdditionalData>
            <ns8:AdditionalData Name="usr_locked">
               <ns9:Value>0</ns9:Value>
            </ns8:AdditionalData>
            <ns8:AdditionalData Name="usr_disabled">
               <ns9:Value>0</ns9:Value>
            </ns8:AdditionalData>
         </ns8:UserData>
      </part>
   </beneficiaryUserDetails>
</messages>

请求请查看架构并建议架构可能出现的问题。

0 个答案:

没有答案