当我尝试从部署到 WebSphere 7.0 的类调用 WebService(HP-Service Manager,如果它有帮助的话)时出现错误。当我调用它时,相同的代码起作用从 JUnit 代码...
WSDL的片段是:
<definitions targetNamespace="http://schemas.hp.com/SM/7"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://schemas.xmlsoap.org/wsdl/ http://schemas.xmlsoap.org/wsdl/">
我认为 xmlns:xsi
总是被 XML 解析器识别,所以我不明白这个错误。为什么在 WebSphere 上会出现此类错误,而在 JUnit 中使用 com.ibm.ws.webservices.thinclient
启动代码时却不会出现?
适当的 StackTrace 片段是:
Caused by: javax.wsdl.WSDLException: WSDLException: faultCode=PARSER_ERROR: Problem parsing 'wsjar:file:/path/to/ear.ear/war.war/WEB-INF/lib/my_jar-0.0.1-SNAPSHOT.jar!/wsdl/myWsdl.wsdl'.: org.xml.sax.SAXParseException: Das Präfix "xsi" für Attribut "xsi:schemaLocation", das einem Elementtyp "definitions" zugeordnet ist, ist nicht gebunden. at com.ibm.wsdl.xml.WSDLReaderImpl.getDocument(WSDLReaderImpl.java:2255) at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(WSDLReaderImpl.java:2330) at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(WSDLReaderImpl.java:2296) at org.apache.axis2.jaxws.util.WSDL4JWrapper$13.run(WSDL4JWrapper.java:745) at org.apache.axis2.java.security.AccessController.doPrivileged(AccessController.java:132) at org.apache.axis2.jaxws.util.WSDL4JWrapper.loadDefinition(WSDL4JWrapper.java:742) ... 51 more Caused by: org.xml.sax.SAXParseException: Das Präfix "xsi" für Attribut "xsi:schemaLocation", das einem Elementtyp "definitions" zugeordnet ist, ist nicht gebunden. at org.apache.xerces.parsers.DOMParser.parse(Unknown Source) at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source) at com.ibm.wsdl.xml.WSDLReaderImpl.getDocument(WSDLReaderImpl.java:2245) ... 56 more
最佳答案
错误的意思正是它所说的:xsi 前缀没有命名空间声明。
XML 解析器并不具备此 namespace 的内置知识。需要声明它以使文档命名空间格式正确。
关于java - SAX 解析异常 : The prefix "xsi" for attribute "xsi:schemaLocation" is not bound,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16690404/