使用XML替代组时,在使用Oracle jdk1.8.0_121的Weblogic 12.2.1上的验证问题

时间:2019-03-14 09:34:46

标签: java xml validation weblogic12c xerces

当未验证SOAP消息中的Web服务响应时,我们在使用Oracle JDK 1.8.0_121的Weblogic 12.2.1.2上遇到了一个奇怪的XML验证问题:

2018-11-22 15:12:56,813 - WARN wsproxy.validation.SchemaValidationErrorHandler - Schema validation error
org.xml.sax.SAXParseException; cvc-complex-type.2.4.a: Invalid content was found starting with element 'aixm:Curve'. One of '{"http://www.opengis.net/gml/3.2":AbstractCurve}' is expected.
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:203)
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:134)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:396)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:327)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:284)
    at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(XMLSchemaValidator.java:452)
    at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.reportSchemaError(XMLSchemaValidator.java:3230)
    at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:1790)
    at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement(XMLSchemaValidator.java:740)
    at com.sun.org.apache.xerces.internal.jaxp.validation.DOMValidatorHelper.beginNode(DOMValidatorHelper.java:277)
    at com.sun.org.apache.xerces.internal.jaxp.validation.DOMValidatorHelper.validate(DOMValidatorHelper.java:244)
    at com.sun.org.apache.xerces.internal.jaxp.validation.DOMValidatorHelper.validate(DOMValidatorHelper.java:190)
    at com.sun.org.apache.xerces.internal.jaxp.validation.ValidatorImpl.validate(ValidatorImpl.java:109)
    at javax.xml.validation.Validator.validate(Validator.java:124)

SOAP响应相关部分:

xmlns:aixm="http://www.aixm.aero/schema/5.1"
xmlns:gml="http://www.opengis.net/gml/3.2"

<gml:curveMember xlink:type="simple">
    <aixm:Curve gml:id="uuid.53b4d3b8-3869-4c3e-a54d-2a003fc8def2">
        <gml:segments>
            <gml:GeodesicString interpolation="geodesic">
                <gml:posList>43.0000 -3.0000 43.1000 -3.1000 43.2000 -3.2000 43.0000 -3.0000</gml:posList>
            </gml:GeodesicString>
        </gml:segments>
    </aixm:Curve>
</gml:curveMember>

然后,当我们查看GML的架构定义时:

<element name="curveMember" type="gml:CurvePropertyType"/>
<complexType name="CurvePropertyType">
    <annotation>
        <documentation>A property that has a curve as its value domain may either be an appropriate geometry element encapsulated in an element of this type or an XLink reference to a remote geometry element (where remote includes geometry elements located elsewhere in the same document). Either the reference or the contained element shall be given, but neither both nor none.</documentation>
    </annotation>
    <sequence minOccurs="0">
        <element ref="gml:AbstractCurve"/>
    </sequence>
    <attributeGroup ref="gml:AssociationAttributeGroup"/>
    <attributeGroup ref="gml:OwnershipAttributeGroup"/>
</complexType>

和AIXM模式:

<element name="Curve" type="aixm:CurveType" substitutionGroup="gml:Curve"/>
<complexType name="CurveType">
    <complexContent>
        <extension base="gml:CurveType">
            <sequence>
                <group ref="aixm:CurvePropertyGroup"/>
            </sequence>
        </extension>
    </complexContent>
</complexType>

在调查过程中我们发现,当使用替代组时,Xerces 2.11中确实存在验证问题: https://jira.apache.org/jira/browse/XERCESJ-1577

因此,我们尝试将Weblogic配置为使用新版本2.12和旧版本2.9.1,但结果相同:

2019-02-27 10:32:00,556 - WARN wsproxy.validation.SchemaValidationErrorHandler - Schema validation error
org.xml.sax.SAXParseException; cvc-elt.4.2: Cannot resolve 'aixm:CurveType' to a type definition for element 'gml:Curve'.
    at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
    at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
    at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
    at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
    at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
    at org.apache.xerces.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(Unknown Source)
    at org.apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(Unknown Source)
    at org.apache.xerces.impl.xs.XMLSchemaValidator.getAndCheckXsiType(Unknown Source)
    at org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source)
    at org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown Source)
    at org.apache.xerces.jaxp.validation.DOMValidatorHelper.beginNode(Unknown Source)
    at org.apache.xerces.jaxp.validation.DOMValidatorHelper.validate(Unknown Source)
    at org.apache.xerces.jaxp.validation.DOMValidatorHelper.validate(Unknown Source)
    at org.apache.xerces.jaxp.validation.ValidatorImpl.validate(Unknown Source)
    at javax.xml.validation.Validator.validate(Validator.java:124)

值得一提的是,当我们在XMLSpy或SoapUI 5.4(使用Xerces 2.9.1)中手动验证响应时,响应似乎是有效的。知道有什么问题吗?

0 个答案:

没有答案