As part of trying to learn WCF, I am reading up on serialization. I am struggling to understand how I can control serialization in .NET 3.5. For instance, I have a simple class with a few public properties. By adding the DataContract attribute to that class, I can for instance control the namespace and the name of the class as it is serialized.
On the other hand, I could add the Serializable attribute (probably not even necessary) and an XmlType attribute, which also allows me to control the namespace and the name that is used for serializing the class.
I implemented both approaches and use the class in a ServiceContract as part of an interface call. I then use a Http analyzer to see how the various objects are serizalized and I noticed that the XmlType did not influence the xml in the http at all.
I have been trying to understand this all day. What am I missing?
Update: I do understand the difference between the two and why they are there. I just don't understand why I cannot influence the generated xml with XmlType or (just tried it XmlRoot).
Basically, you can control all details of the serialization by implementing IXmlSerializable, except the namespaces and the name of the top level element. For that, I was assuming that you would need the XmlType or XmlRoot attribute. Was I wrong?