Monday, July 14, 2008 1:05 AM
I am writing a WCF Service.
I am having a Products class which derives from a List collection. Now there are other classes which are similar to this class. So i am having an interface as IBase and all my classes implement this interface. When i implemented my service, i am able to access all my classes, but my IBase interface is not visible from client side. I am not able to mark interface as DataMember. Can anyone help me how to expose my interface to the client? IBase interface is not a service contract. It is just an interface which all my entity objects implement.
Thanks and Regards,
Tuesday, July 15, 2008 2:15 PMModeratorSorry, but interfaces can not be exposed to a client via wsdl because an interace doesnt really expose data so it cant be a data contract. Your only realy option is to expose a shared library between the client and server. This shared library can be as rich as you want with interfaces and oteh classes.
Wednesday, July 16, 2008 5:34 PMThere is a way to mention KnownType for a DataContract. Will that allow to expose the dependent Interfaces? Do
have any idea about this. I am going to try this.
Wednesday, July 16, 2008 5:38 PMModeratorKnownType attribute is a way to ensure that the type data for teh contract is added to the wsdl metadata. This only works for classes it will not work for an interface. An interface cant store data and is not univerally understood by all languages out there so its not really exposable over wcf.
Tuesday, July 22, 2008 12:08 AMThanks for the reply i got my answer
Tuesday, July 22, 2008 9:49 AM
Hi - have a look at the below esp. from Marc Gravell - you can re-use the entity classes on both sides of the interface.
Adding the [KnownType] attributes on any polymorphic base class should avoid most deserialization issues.
Thursday, July 24, 2008 8:53 PMWell i am looling to share the Interface itself not the entity class. I am not sure if your links speaks about that.