first_page the funky knowledge base
personal notes from way, _way_ back and maybe today

WCF: “Since a WCF service can return any user defined class, why use a DataContract and CompositeType class?”; StackOverflow.com

Blankman: Since a WCF service can return any user defined class, why use a DataContract and CompositeType class?

I can return something like:

[OperationContract] MyUserCollection GetUsers();

What am I missing?

Guy Starbuck: The DataContract is just a formal definition of a type that can be understood on both sides of the service boundary.

If you return, as in your example, a "MyUserCollection" object, the consumers of your service will need to reference the innards of your service/system, which is a violation of the SOA tenet of explicit boundaries. By using a DataContract, you are publishing the structure of your return types in a loosely-coupled way.

[http://stackoverflow.com/questions/303013/whats-the-point-of-a-datacontract-in-wcf]

mod date: 2009-08-28T04:50:32.000Z