Hi
The solution for your question is depend in the solution you are trying to achieve by
separating the service contract to 2 different interfaces.
In the following example i have chosen the simple answer to that problem
The current solution depend on the fact that WCF based on Service Contracts Implemented via Interfaces and exposed to the world via Endpoints (with the ABC properties)
Basically the Service Implementation does not exposed to the end user.
So we can implement the 2 different Service Contract in the same service Implementation
And expose it as 2 End Points
Check the following code:
[ServiceContract]
public interface IFooService
{
[OperationContract]
void Foo();
}
[ServiceContract]
public interface IBarService
{
[OperationContract]
void Bar();
}
public class Service : IFooService, IBarService
{
public void Foo()
{
Console.WriteLine("Foo Service Method Call");
}
public void Bar()
{
Console.WriteLine("Bar Service Method Call");
}
}
class Program
{
static void Main(string[] args)
{
try
{
using (ServiceHost host = new ServiceHost(typeof (Service)))
{
host.Open();
Console.WriteLine("S E R V E R");
Console.WriteLine("Press any key to shutdown");
Console.ReadKey();
host.Close();
}
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
}
<configuration>
<system.servicemodel>
<behaviors>
<servicebehaviors>
<behavior name="ServiceBehavior">
<servicemetadata httpgetenabled="true" />
</behavior>
<behavior name="">
<servicemetadata httpgetenabled="true" httpsgetenabled="true" />
<servicedebug includeexceptiondetailinfaults="false" />
</behavior>
</servicebehaviors>
</behaviors>
<services>
<service behaviorconfiguration="ServiceBehavior" name="ConsoleApplication2.Service">
<endpoint address="Foo" binding="basicHttpBinding" name="Foo">
contract="ConsoleApplication2.IFooService" />
<endpoint address="Bar" binding="basicHttpBinding" name="Bar">
contract="ConsoleApplication2.IBarService" />
<host>
<baseaddresses>
<add baseaddress="http://localhost:8733/Design_Time_Addresses/ConsoleApplication2/Service" />
</baseaddresses>
</host>
</endpoint></endpoint></service>
</services>
</system.servicemodel>
</configuration>