Мы столкнулись со странной проблемой проверки XML в Weblogic 12.2.1.2 с использованием Oracle JDK 1.8.0_121, когда ответ веб-службы в сообщении SOAP не был проверен:
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), тогда ответ представляется действительным. Есть идеи, что может быть не так?