3

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>  
FrankS77
  • 271
  • 4
  • 17

1 Answers1

2

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>
kjhughes
  • 106,133
  • 27
  • 181
  • 240
  • You might think I'm stupid or something but I still getting the same error. I use your SOAP Envelope as XML and my XSD with a added targetNamespace="http://schemas.xmlsoap.org/soap/envelope/" and getting a -----> Cvc-elt.1: Cannot Find The Declaration Of Element 'soapenv:Envelope'.. Line '4', Column '78'. – FrankS77 Apr 16 '15 at 12:59
  • No, it's probably just a simple mistake you're making, but I can't tell without seeing your exact work. Start here: Paste the minimal SOAP message from my answer into the validation service. Use this for the URL field: `http://schemas.xmlsoap.org/soap/envelope/`. I just checked and it works at your online XPath site: http://www.freeformatter.com/xml-validator-xsd.html Once you confirm that this works, take small steps to adjust it to match what you want to do, re-validating each step along the way. – kjhughes Apr 16 '15 at 13:29
  • Yes you are right. If I take your SOAP message and this URL (http://schemas.xmlsoap.org/soap/envelope/) as my XSD than it works! but I know now ( I googled a lot) that I made a mistake and not say that my XML contains more than one namespace (also a custom namespace). So the XML (with SOAP and custom namespace) must validate against a custom (file) XSD. Sorry for the confusions :-( – FrankS77 Apr 17 '15 at 07:47
  • That's ok, but I'm not clear on whether you all set now or still need further help. – kjhughes Apr 17 '15 at 13:54
  • I need to rethink my question. Maybe I have to ask another question later. Many thanks !!!! – FrankS77 Apr 20 '15 at 06:40