XSD validation error: Cannot Find The Declaration Of Element 'soapenv:Envelope'

XSD validation error: Cannot Find The Declaration Of Element 'soapenv:Envelope'

我尝试使用 http://www.freeformatter.com/xml-validator-xsd.html 验证我的 XML 与我的 XSD,但它失败并出现上述错误。 我发现了许多相同的问题,但 none 的答案对我有所帮助。 请帮忙,正确的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)。

  • 您的 XML SOAP 命名空间 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>