Link to home
Start Free TrialLog in
Avatar of Yampolka
Yampolka

asked on

Can I use Serializable Attribute instead of DataContract Attribute in WCF ?

I have a goal to migrate WEB Services to  WCF( wsHttpBinding;)
Is it possible  DO not PROVIDE A  DataContract attribute   for classes/ parameters migrated ,
just live  Serializable Attribute instead?
Avatar of BuggyCoder
BuggyCoder
Flag of India image

Yes it is, the only difference however is that using serializable you can only serialize fields and not properties.

Also serializable work on opt out model where in a field that don't want to get serialized has to mark itself as nonserialized, however DataContract works on OptIn approach where any property that wants to get serialized has to mark itself as DataMember.

Also serializable will serialize the assembly information in stream along with object state, however DC only writes state to stream(XML) which is what is required in SOA.

Here is a comparison:-
http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/be796bd0-2502-4bd3-96d9-60bf7d68930d/
http://msdn.microsoft.com/en-us/library/ms730035.aspx
Avatar of Yampolka
Yampolka

ASKER

Thanks a lot .
As I understood correctly  serializable and datacontract attributes provide different serialization engines behind the scenes. If some classes  are serializable by default    and do not need 'serializable' attribute  to be serialized   like Dataset ?
Should I provide DataContract  attribute for DataSet?.
How WCF works with ADO.NET classes ?What kind of serialization it use?
And  could you  please tell  me what does it mean opt out and opt in model?
ASKER CERTIFIED SOLUTION
Avatar of BuggyCoder
BuggyCoder
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial