Last post Jun 21, 2013 04:43 PM by Spider.net
Jun 21, 2013 05:08 AM|rbodhale|LINK
Why interface are use in WCF in service contract ? We can achive the same functionality by using abstract class but why interface are prefered in WCF over abstract class ?
Jun 21, 2013 05:28 AM|DarrellNorton|LINK
If you use an abstract class, it will compile correctly but at runtime you will get an error like "Contract inheritance can only be used among interface types."
It will work if you include the [ServiceKnownType] (on a Service Contract) or [KnownType] on a Data Contract. Basically you have to tell WCF what to serialize/deserialize.
Jun 21, 2013 09:42 AM|Illeris|LINK
And additionally : objects in .NET can only inherit from one other object. An interface is a way to enforce object behavior according to the scheme described in the interface. An object can hence implement many interfaces.
In many SOA logic implementations, the notion of use case is translated into a Service Contract (interface). A service component can implement many service interfaces, for example when grouping functionality that belongs together and to allow reuse of specific
code (private members, ...)
Jun 21, 2013 04:43 PM|Spider.net|LINK
Actually, ServiceContract and OperationContract can be used on classes directly instead of just interfaces
You can check the URL for more