Search code examples
wcfserializationdatacontractxmlserializer

WCF Data Contract / Serialization


I created a simple WCF application which expose one operation. This operation takes a composite data type as parameter.

I have not decorated this composite data type with [DataContract] attribute. But this is working and I can see the Schema for this in WSDL.

Now my understanding is that this new custom type should be decorated with [Serializable] or [dataContract] attribute to take part in the Web services operation.

What I am missing here?


Solution

  • POCO support have been introduced in WCF since .NET 3.5 SP1 and you no longer need to decorate your objects with [DataContract] and [DataMember] attributes. Public properties will be automatically exposed. Although I would recommend you explicitly marking them with those attributes.