By default, WCF runtime uses
DataContractSerializer to perform data serialization and deserialization. However, in some cases, we will prefer using
XMLSerializer, which will give developers more control over the serialized XML content or will work more closely with some POX clients (like ASMX Web Service client).
XMLSerializer. This can be done by adding XML serialization attributes on our data types. The following
Userclass has been decorated with several XML serialization attributes (
XmlRootAttributefor top-level type and
XmlElementAttributefor type members).
[XmlRoot(ElementName="UserObject",Namespace= "http://wcftest.org/xmlserializer")] ...