XML : C# Validate XmlElement against Visual Studio Generated XSD Class

I have a soap service which receives a partial class 'Test', a class which was created from an XSD within Visual Studio 2013.

Soap

  [WebMethod(Description = "Test SOAP Service")]  public XmlDocument TestSoap(Test test)  {  }    

Test.cs

  using System.Xml.Serialization;    [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.33440")]  [System.SerializableAttribute()]  [System.Diagnostics.DebuggerStepThroughAttribute()]  [System.ComponentModel.DesignerCategoryAttribute("code")]  [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]  [System.Xml.Serialization.XmlRootAttribute(Namespace="", IsNullable=false)]  public partial class Test {          }    

I believe the normal way to validate the XSD Schema is against an XML Document, similar to this example 'Xml validation using XSD schema' but in my case I don't have the outer XML.

Can somebody please explain how I might validate the input data against the schema/class?

No comments:

Post a Comment