FrankS77
FrankS77

Reputation: 311

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

I try to validate my XML against my XSD using http://www.freeformatter.com/xml-validator-xsd.html but it fails with the error above. I found many of the same questions but none of the answers helped me. Please help, what is the correct XML/XSD?

My XML: (only the minimal one)

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope" >
</soapenv:Envelope>

My XSD: (only the minimal one)

<?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>  

Upvotes: 3

Views: 9858

Answers (1)

kjhughes
kjhughes

Reputation: 111726

Several issues:

  • Your XML does not hint as to the location of an XSD.

    Remedy: Use xsi:schemaLocation (see XSD below).

  • Your XML namespace URI for SOAP is non-standard.

    Remedy: Use http://schemas.xmlsoap.org/soap/envelope/ (note trailing slash).

  • Your XSD does not define a targetNamespace.

    Remedy: Define one, or better yet, use the standard Schema for the SOAP/1.1 envelope.

You can use the following null SOAP envelope message to check your message; it will eliminate your error and allow the declaration of soapenv:Envelope to be found:

Minimal Valid SOAP Envelope

<?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>

Upvotes: 2

Related Questions