I used XSD2Code to generate C# code from given XSD. This tool generated code snipped as below:
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]
[System.Xml.Serialization.XmlRootAttribute(Namespace = "", IsNullable = false)]
public partial class Orders
{
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified, Order = 0)]
public int OrderID {get;set;}
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified, Order = 1)]
public string Description {get;set;}
}
Coud some one please guide me with following queires, please
-
If I leave the above code as it is, does WCF serializes the above class?
Currently I’m getting this error on wcf test client: “”this Operation is not
supported in WCF Test Client”. -
Do I need to add DataContract and DataMember on top of the above generated codes?
- Which option is beter between DataContract Serializer vs XML Serializer
Thanks you.
[XmlSerializerFormat]attribute[XmlSerializerFormat], the DataContract/DataMember attributes are ignored (the XML serialization attributes, like the ones in this type, are used instead)XmlSerializerallows you to completely control the XML in which the types are serialized; theDataContractSerializer(DCS) doesn’t (it’s more limited). But the DCS has a better performance, so which one is better really depends on your scenario.The code below shows a service which uses this type, and it works fine, even with the WcfTestClient.