Is there any generic way to add transport security to client endpoint binding dynamically for WCF service?
The binding can be accessed using proxyObject.Endpoint.Binding property. The Security property for each binding is specific to each binding.
Edit:
If binding cannot be updated after proxy is created, is there any generic way to configure proxy binding with transport security. I am using below overload to create proxy. The binding needs to be created based on client endpoint and binding configuration defined in configuration file.
protected ClientBase(Binding binding, EndpointAddress remoteAddress);
My Code:
Binding binding;
// Code to create binding using details from configuration file goes here...
// For example, if configuration uses BasicHttpBinding,
// then here we will create object of "BasicHttpBinding" and
// set its Security mode as Transport
TServiceProxyInterface serviceProxy = (TServiceProxyInterface)Activator.CreateInstance(
TServiceProxyClass,
binding,
new EndpointAddress(serviceAddress));