Why are attributes not supported by DataContractSerializer?

I am creating xsd based on client documentation and all xsd attributes. I use xsd.exe to generate classes from xsd, but I read that these attributes are not supported for DataContractSerializer. Why not? Does this mean that I can only have a soap + xml file with just elements? This is not possible because I am not creating queries. Is there a way to specify svcutil for attribute recognition?

+3
source share
1 answer

The DataContractSerializer was created taking into account the philosophy of the "first code" - it displays most programming languages ​​well (records, lists), and it does not process all XML constructs (such as attributes or out-of-order elements, for example) for performance reasons.

WCF (svcutil) still supports the use of XmlSerializer, which can handle AFAIK of all XML constructs. svcutil must create a contract using XmlSerializer if the DataContractSerializer cannot process it.

+5
source

All Articles