我尝试使用 http://www.freeformatter.com/xml-validator-xsd.html 根据我的 XSD 验证我的 XML但它因上述错误而失败。 我发现了许多相同的问题,但没有一个答案对我有帮助。 请帮忙,什么是正确的 XML/XSD?
我的 XML:(只有最小的)
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope" >
</soapenv:Envelope>
我的XSD:(只有最小的)
<?xml version="1.0" encoding="ISO-8859-1"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" >
</xs:schema>
最佳答案
几个问题:
您的 XML 没有暗示 XSD 的位置。
补救措施:使用
xsi:schemaLocation
(参见下面的 XSD)。您的 SOAP 的 XML 命名空间 URI 是非标准的。
补救措施:使用
http://schemas.xmlsoap.org/soap/envelope/
(注意尾部斜线)。您的 XSD 未定义
targetNamespace
。补救措施:定义一个,或者更好的是,使用 standard Schema for the SOAP/1.1 envelope .
您可以使用以下空 SOAP 信封消息来检查您的消息;它将消除您的错误并允许找到 soapenv:Envelope
的声明:
最小有效 SOAP 信封
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://schemas.xmlsoap.org/soap/envelope/
http://schemas.xmlsoap.org/soap/envelope/"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" >
<soapenv:Body/>
</soapenv:Envelope>
关于xml - XSD 验证错误 : Cannot Find The Declaration Of Element 'soapenv:Envelope' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29668784/