This is how I have setup a multiple "Services" (Interfaces) within in a single host. Way I understand the WCF is that it acts as a virtual .Dll. As such, you can practically place every routine in the WCF space.
Scenarios:
public
class
Service1 : IService1
{
public Service2 Service2 { get; set; }
public Service3 Service3 { get; set; }
public Service4 Service4 { get; set; }
}
You want to able to do some routines that are required by Service2..4. Let's say that each one of them has (add/update, delete, get) functions. You could insert them into the IService1. However, you would have too many methods. So, I thought of creating separate services for separate classes. I am sure there are better ways. I do not know the better ways as of today (03/05/2009). I have not been able to use generics or something bit clever or elegant.
This is what I came up for my self-technical constraints.
<system.serviceModel>
<bindings />
<services>
<service
behaviorConfiguration="WCFLibrary.Service1Behavior"
name="WCFLibrary.MyService">
<clear />
<endpoint
binding="wsHttpBinding"
contract="WCFLibrary.IService1"
listenUriMode="Explicit">
<identity>
<dns
value="localhost" />
identity>
endpoint>
<endpoint
address="mex"
binding="mexHttpBinding"
name="mex"
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add
baseAddress="http://localhost:8080/MyService1" />
</baseAddresses>
</host>
</service>
<service
behaviorConfiguration="WCFLibrary.Service1Behavior"
name="WCFLibrary.MyService2">
<endpoint
address=""
binding="wsHttpBinding"
bindingConfiguration=""
contract="WCFLibrary.IService2" />
<endpoint
address="mex"
binding="mexHttpBinding"
name="mex"
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add
baseAddress="http://localhost:8080/MyService2" />
</baseAddresses>
</host>
</service>
<service
behaviorConfiguration="WCFLibrary.Service1Behavior"
name="WCFLibrary.MyService3">
<endpoint
address=""
binding="wsHttpBinding"
bindingConfiguration=""
contract="WCFLibrary. IService3" />
<endpoint
address="mex"
binding="mexHttpBinding"
name="mex"
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add
baseAddress="http://localhost:8080/MyService3" />
</baseAddresses>
</host>
</service>
<service
name="WCFLibrary.MyService4"
behaviorConfiguration="WCFLibrary.Service1Behavior">
<endpoint
address=""
binding="wsHttpBinding"
bindingConfiguration=""
contract="WCFLibrary.IService4" />
<endpoint
address="mex"
binding="mexHttpBinding"
name="mex"
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add
baseAddress="http://localhost:8080/MyService4" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior
name="WCFLibrary.Service1Behavior">
<serviceMetadata
httpGetEnabled="true" />
<serviceDebug
includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>