Here I answer my question again: -S
I solved this by writing NetTcpServiceLocator ...
public interface INetTcpServiceLocator { EndpointAddress GetAddress(Type serviceType); }
... along with a custom configuration section handler that also implements the above interface and reads in the next configuration section ...
<services> <service contract="My.Services.TestService.Contracts.ITestService" address="net.tcp://localhost/TestService" /> </services>
Then I created a proxy for each service ...
public class TestServiceProxy : ITestService { public SomeInformation GetSomeInformation(SomeParams @params) { using (var factory = new NetTcpServiceFactory<ITestService>()) { var service = factory.Service; return service.GetSomeInformation(@params); } } }
My controller has a dependency on a Service that has a dependency on ITestService. All of this is glued together with Castle Windsor and with an injection of dependency property.
So, my controller calls this Service, which in turn calls ITestService (in this case, the proxy that receives the endpoint from the user section handler).
The user section handler (which is also an INetTcpServiceLocator) has the "perWebRequest" windsor style, so it is called by the framework, and web.config is read into an array in memory. When a service proxy is called, it simply pulls the corresponding endpoint based on the type of contract.
It all depends on the type of contract, so there is no longer any need for any variables in web.config.
I went for a code-based solution, since I do not use the build process locally, only when I submit my code to subversion, the build process runs on our build server.