LEADTOOLS WCF Send comments on this topic. | Back to Introduction - All Topics | Help Version 17.0.3.22
Data Contracts and Service Contracts (WCF)

DataContract

A DataContract is a formal agreement between a service and a client on how data will be exchanged. It also describes how data is to be serialized. A DataContract is used when complex data types are needed to be exchanged between the server and client. A class has to be marked with the DataContract attribute for it to be serialized and exposed in the WCF Service. Any class that does not have the DataContract attribute is not accessible in the WCF Service.

Data Contracts are used by Service Contracts like primitive data types. DataContract objects can be passed as parameters for Service Contracts or returned as values for the Service Contracts.

For more information you can refer to the MSDN article: Using Data Contracts

ServiceContract

A ServiceContract is a method that is exposed in a WCF Service, which a client calls to execute the service. The ServiceContract almost always has a return value exposed to the client to check if it was successful, or to see if there are any results. A ServiceContract uses Data Contracts to transfer data to and from the client. It can also use primitive data types to transfer data.

For more information you can refer to the MSDN article: Designing Service Contracts