I would like to save the endpoint configuration in a .config file, but be able to change the base address at runtime. EG: these are my endpoint definitions in app.config:
<endpoint address="net.tcp://BASEURI:1001/FooService/"
binding="netTcpBinding" bindingConfiguration="NetTcpBinding_Common"
contract="ServiceContracts.MyService"
name="FooService" />
<endpoint address="net.tcp://BASEURI:1002/BarService/"
binding="netTcpBinding" bindingConfiguration="NetTcpBinding_Special"
contract="ServiceContracts.MyService"
name="BarService" />
Each service uses the same contract ( ServiceContracts.MyService), but lives on a different port, a different path, and sometimes on a different binding configuration.
I want to be able to programmatically extract the address "net.tcp: // BASEURI / FooService /", replace "BASEURI" with the server address, and then pass this as the DuplexChannelFactory address when the client connection is created. EG:
string ServiceToUse = "FooService";
var endpointConfig = SomeFunctionThatGetsTheConfig(ServiceToUse);
string trueAddress = endpointConfig.Address.Replace("BASEURI", "192.168.0.1");
DuplexChannelFactory<FooService> client =
new DuplexChannelFactory<FooService>(ServiceToUse, new EndpointAddress(trueAddress));
, <baseAddress> , - , , URI .
. Proxy, DuplexChannelFactory.