Multiple WCF Services implementing same Service Contract interface
- by andrewczwu
Is it possible for multiple wcf services to implement the same service contract interface?
What I want to do is allow for a test service to be interchangeable for the real service, and to specify which service to be used in the configuration file.
For example:
[ServiceContract]
public interface IUselessService
{
[OperationContract]
string GetData(int value);
}
Test implementation
public class TestService : IUselessService
{
public string GetData(int value)
{
return "This is a test";
}
}
Real class
public class RealService : IUselessService
{
public string GetData(int value)
{
return string.Format("You entered: {0}", value);
}
}