4

I have a class that I want to de-serialize an XML-doc into:

[XmlRoot(ElementName = "MyType", Namespace = "MyNamespace")]
public class MyClass : MyBase { }

And

[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.42")]
[SerializableAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[XmlTypeAttribute(Namespace = "BaseNamespace")]
[XmlRootAttribute("MyBaseType", Namespace = "BaseNamespace", IsNullable = false)]
[GuidAttribute("8d9586ec-f263-48e2-ad47-53093430bce4")]
public class MyBase { }

When deserializing I get an error saying

XML schema file with metadata not found at AAA-Fachschema.xsd":null

This is some simplified Xml:

<?xml version="1.0" encoding="utf-8"?>
<!--some comments -->
<q1:MyType xsi:schemaLocation="http://www.adv-online.de/namespaces/adv/gid/6.0 NAS-Operationen.xsd" xmlns:q1="MyNamespace" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:gco="http://www.isotc211.org/2005/gco" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:gts="http://www.isotc211.org/2005/gts" xmlns:ogc="http://www.adv-online.de/namespaces/adv/gid/ogc" xmlns:wfs="http://www.adv-online.de/namespaces/adv/gid/wfs" xmlns:gss="http://www.isotc211.org/2005/gss" xmlns="BaseNamespace">
</q1:MyType>

And the code deserializing:

using (var reader = new XmlReader(theFile, new XmlReaderSettings { ValidationType = ValidationType.None }))
{
    var ser = new XmlSerializer(typeof(MyClass));
    var o = ser.Deserialize(reader);
}

But I am not at all sure where this Xsd-file is set to be loaded by the serializer.

Does anyone know where to set this information for the serializer or even simplier how to disable the check completely?

MakePeaceGreatAgain
  • 35,491
  • 6
  • 60
  • 111
  • How did you create MyClass? Using a tool? – Kosala W Jan 21 '16 at 08:53
  • As far as I know at least `MyBase` has been created automatically from the Xsd `http://www.adv-online.de/namespaces/adv/gid/6.0 NAS-Operationen.xsd`. However this is another Xsd then that one mentioned in the error-message. – MakePeaceGreatAgain Jan 21 '16 at 08:54
  • Do you have a complete xml or wsdl? Can you try to regenerate MyClass. (You can name it as something else) and then try to Deserialise? – Kosala W Jan 21 '16 at 09:04
  • Well, from our production code this works so I assume the class-definitions are up to date with the actual source-code. This is why I assume further that the serializer can be provided with this information in any way, but I´m not sure where to search for. However I may have a look on what you suggested. – MakePeaceGreatAgain Jan 21 '16 at 09:07

1 Answers1

0

Sounds like you are missing an included schema and the URL from the xsd that you gave doesn't appear to link to a downloadable schema. What happens if you try downloading the schemas from http://repository.gdi-de.org/schemas/adv/nas/6.0 and generating the class from the local files?

It looks like there are a whole series of sub-references to chase down as well, but beginning at the link I gave should help.

JamieSee
  • 12,696
  • 2
  • 31
  • 47