Why does WCF have Interfaces?
I was wondering can I do this:
I have the real wcf service I call out to. Then I also have a mock wcf service that returns demo data.
Can I have them implement the same interface and swap them out?
How would I accomplish this?
WCF has interfaces so that you can seperate the structure of your service contract ( ie methods, classes which are your operation contracts and data contracts etc ) from the actual logic that dictates what your service does.
If your real WCF service and your demo service implement the same interface. Yes you can switch out the logic of both of them depending on if your testing vs the real one. Thats one of the major pro’s of WCF is that it allows you to do this so easily due to the interface being the skeleton for the service you create. As well as allowing you to easily alter the “plumbing” of how WCF allows the service to be consumed.
You can accomplish this by creating a WCF project in Visual studio, this gives you the standard interface and service class implementing the interface and you can build on it from there.