0

I have written a client to a public SOAP web service, using a WSDL and several XSD files supplied by the service provider. I wanted to find an easy way to validate user data against the XSD files, so I used the standard example from MSDN, using an XmlSchemaSet for the XSD files, an XmlReader and a validation routine to catch the error messages. (The code is available at http://msdn.microsoft.com/en-us/library/as3tta56.aspx) It works for some data elements, but others do not throw an error when they are invalid. If I include "ValidationFlags = ValidationFlags Or XmlSchemaValidationFlags.ReportValidationWarnings", I then get a lot of warnings, e.g. "Could not find schema information for the element 'MyRequest'", "Could not find schema information for the attribute 'TheDate'", etc. But I can open the XSD files in the VS2010 IDE, and its XML Schema Explorer shows these elements and attributes.

So my main question to anyone who is familiar with validating XML data in VS2010 in this way is, are there limits to the complexity of the XSD files that the XmlReader validation can handle? Could the prefixes for the Target Namespaces confuse the XmlReader? There are thousands of complex types defined in the schema, spread across 7 XSD files, which is why I wanted this to be handled automatically, rather than me writing a validation routine for each user input field.

Thanks in advance.

user2176753
  • 1,549
  • 1
  • 9
  • 7

1 Answers1

0

The .NET validation may not be perfect, yet it's among the best in the industry. One issue they have for sure is with the schema loader (we use our own), which sometimes gets fooled too easily (I would say). Beside the above, I am not aware of any other limitations, along the lines you described. We routinely use .NET XmlSchemaSet to load and validate XSDs spread across hundreds of files, in all sort of namespace combinations, and with thousands of elements, types, etc.

Petru Gardea
  • 21,373
  • 2
  • 50
  • 62
  • Thanks for responding. I will dig deeper into the XSD files to try to find a pattern to what sort of elements are being ignored. After some research I thought I found that optional elements were being ignored, but it turned out that it did not seem consistent across all optional types. I'll have to carry on on Monday. – user2176753 Apr 06 '13 at 07:21