Is it possible to exchange the endpoint behavior of an endpoint defined in the app.config file?
Basically I have a single endpoint with a defined custom binding. From code I set the endpoint address for the WCF proxy client. I'd like to use different endpoint behaviors depending on the endpoint address.
Pseudocode:
var client = new WcfClient("endpointName", new endpointAddress("https://..."));
client.Endpoint.Behaviors.Add(EndpointBehavior.CreateFromConfig("behaviorName"));
Is this (easily) possible? I'd still like to have my behavior definitions in the app.config, but load them dynamically depending on the endpoint's address.
You can access the configuration via System.ServiceModel.Configuration namespace. Read the corresponding sections and construct your endpoint/behaviors manually...
You can also create multiple endpoints and instantiate the client by name: http://msdn.microsoft.com/en-us/library/ms751515.aspx
You can also try to use BehaviorExtensionElement from the configuration namespace to try to create a behavior. I found an example here: http://weblogs.asp.net/cibrax/archive/2010/05/11/getting-wcf-bindings-and-behaviors-from-any-config-source.aspx
For the server for example: If the ServiceHost instance is already open, you can also access most information from it directly