There are 2 main entities in WCF.
Interface
and
Class
Interface
will represent a skeleton of the
class
, where
class
actually holds body.
So you need to apply
ServiceContract
on Interface itselft and
OperationContract
on each methods the interface is exposing.
Whenever you create an object based on the methods exposed by the interface, you need to serialize everything which is going to travel from one app-domain to another. otherwise you will get SerializationException.
so you make
class
itself,
DataContact
and each member of the class you are exposing
DataMember
. Now you dont need to make native data types (int, decimal, etc...) serializable. they have default DataContracts associated with them. so anything which is non-native data type i.e. class, struc, dataset, enum etc.. you have to make it DataContract.
that's why you need to tag your class
MembersService with [DataContract] attribute and Property/Fields i.e. clsProduct,clsOrder,clsCustomer (please use Property instead of public variable) as [DataMember].
Also note that DataTable is not serializable so please use DataSet instead.
Please refer this MSDN Article for more information.[
^]
:)