How do I return an interface from a WCF Service?
wcf, wcf-client
Solution
IBar needs to be concrete and a DataContract. WCF isn't about distributed objects, but rather a way to transfer data and have services work on that data. You can't return an object in WCF that has behavior.
Problem
Lets say I have some interfaces: ``` public interface IFoo { IBar DoesStuff(); } public interface IBar { string Thingo { get; } } ``` I'm consuming this code throughout my code base. The IFoo process needs to be moved onto a different system (a difference of x64 vs x32), this is our reason for using WFC. My WCF service implements this interface. When I create the "service reference" the proxy stubs are created but the interface is altered. ``` public interface IFoo { object DoesStuff(); } ``` I tried defining IBar/Bar as both a DataService and DataContract with no difference. Is there a way to generate the proxy code using my interface? I'm thinking if mock objects can produce a object of my interface for testing, then shouldn't I be able to get the service to honor it as well? Or did do something silly and wrong?