I have a bunch of self-hosted WCF services. Everything's working fine but I'm look for ways to normalize/simplify the resultant config. I've simplified it as much as possible, but I'm still not happy. Currently, my config looks like this:
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="BindingConfiguration" ...>
...
</binding>
</netTcpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
...
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="ServiceBehavior" name="Name1">
<endpoint address="net.tcp://localhost:8080/name1" binding="netTcpBinding" bindingConfiguration="BindingConfiguration" contract="Contract1">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</service>
<service behaviorConfiguration="ServiceBehavior" name="Name2">
<endpoint address="net.tcp://localhost:8080/name2" binding="netTcpBinding" bindingConfiguration="BindingConfiguration" contract="Contract2">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</service>
...
</services>
</system.serviceModel>
In all, I have 6 services so it's repetitive. Ideally, I'd like:
- To specify "localhost:8080" only once and share between all services, and only specify the difference ("name1" or "name2")
- Specify the identity information only once and share between all service definitions
To my first point, I've aware of base addresses, but that only works at the service level, not across separate services. To my second point, I've tried moving the identity information into an endpoint behavior, but that doesn't appear to be supported.
Is there anything I can do to simplify this config? Or is my only option to switch to a code-based configuration approach?