使用 Xerces 验证带有 XSD 导入的 WSDL 失败,并显示“已指定属性”

问题描述

对于 SOAP 网络服务,在客户端,我们使用 WSDL 通过

导入多个 XSD
<xsd:import ...

XSD 包含相同的导入语句 (<xsd:import...) 以便我们获得类似

的导入结构
wsdl -> A.xsd,B.xsd,C.xsd
A.xsd -> B.xsd,C.xsd
B.xsd -> X.xsd

通过 jaxws-rt 2.2.10 使用 Xerces(版本 2.12.1)执行的验证会导致如下错误消息:

MyWSDL.wsdl#schema0; lineNumber: 1; columnNumber: 1186; Attribute "xsd" bound to namespace "http://www.w3.org/2000/xmlns/" was already specified for element "xsd:schema".

堆栈跟踪是:

at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(UnkNown Source) ~[xercesImpl-2.12.1.jar:?]
    at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(UnkNown Source) ~[xercesImpl-2.12.1.jar:?]
    at org.apache.xerces.impl.XMLErrorReporter.reportError(UnkNown Source) ~[xercesImpl-2.12.1.jar:2.12.1]
    at org.apache.xerces.impl.XMLErrorReporter.reportError(UnkNown Source) ~[xercesImpl-2.12.1.jar:2.12.1]
    at org.apache.xerces.impl.XMLErrorReporter.reportError(UnkNown Source) ~[xercesImpl-2.12.1.jar:2.12.1]
    at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(UnkNown Source) ~[xercesImpl-2.12.1.jar:2.12.1]
    at org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentdispatcher.scanRootElementHook(UnkNown Source) ~[xercesImpl-2.12.1.jar:2.12.1]
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentdispatcher.dispatch(UnkNown Source) ~[xercesImpl-2.12.1.jar:2.12.1]
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(UnkNown Source) ~[xercesImpl-2.12.1.jar:2.12.1]
    at org.apache.xerces.impl.xs.opti.SchemaParsingConfig.parse(UnkNown Source) ~[xercesImpl-2.12.1.jar:?]
    at org.apache.xerces.impl.xs.opti.SchemaParsingConfig.parse(UnkNown Source) ~[xercesImpl-2.12.1.jar:?]
    at org.apache.xerces.impl.xs.opti.SchemaDOMParser.parse(UnkNown Source) ~[xercesImpl-2.12.1.jar:?]
    at org.apache.xerces.impl.xs.traversers.XSDHandler.getSchemaDocument(UnkNown Source) ~[xercesImpl-2.12.1.jar:?]
    at org.apache.xerces.impl.xs.traversers.XSDHandler.resolveSchema(UnkNown Source) ~[xercesImpl-2.12.1.jar:?]
    at org.apache.xerces.impl.xs.traversers.XSDHandler.constructTrees(UnkNown Source) ~[xercesImpl-2.12.1.jar:?]
    at org.apache.xerces.impl.xs.traversers.XSDHandler.parseSchema(UnkNown Source) ~[xercesImpl-2.12.1.jar:?]
    at org.apache.xerces.impl.xs.XMLSchemaLoader.loadSchema(UnkNown Source) ~[xercesImpl-2.12.1.jar:?]
    at org.apache.xerces.impl.xs.XMLSchemaLoader.loadGrammar(UnkNown Source) ~[xercesImpl-2.12.1.jar:?]
    at org.apache.xerces.impl.xs.XMLSchemaLoader.loadGrammar(UnkNown Source) ~[xercesImpl-2.12.1.jar:?]
    at org.apache.xerces.jaxp.validation.XMLSchemaFactory.newSchema(UnkNown Source) ~[xercesImpl-2.12.1.jar:?]
    at com.sun.xml.ws.client.ClientSchemaValidationTube.<init>(ClientSchemaValidationTube.java:93) ~[jaxws-rt-2.2.10.jar:2.2.10]

这个好像跟import有关,还是有其他解释?是否可以停用由 org.apache.xerces.jaxp.validation.XMLSchemaFactory 触发的 WSDL 验证?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)