xml - XSD 验证错误 : Cannot Find The Declaration Of Element 'soapenv:Envelope'

标签 xml xsd

我尝试使用 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/

相关文章:

xml - 如何将参数值传递给 XSL?

visual-studio - 将 XML 架构添加到 Visual Studio

c# - 如何在 WCF 中返回 DataSet (xsd)

xslt - XSLT : How to reorder entries according to the dependencies 的 XSD 转换

xml - cvc-enumeration-valid : Value '2' is not facet-valid with respect to enumeration '[1]' . 它必须是枚举中的一个值

c# - '='字符,十六进制值0x3D,不能包含在名称中

sql - 如何根据XSD从数据库导出数据到xml

xml - 这是 scala.xml.Elem 中的错误吗?

xml - postgresql query_to_xml 删除标签 'row'

java - Spring JAXB - 使用模式验证解码 XML 文档