How can I dynamically set the Security mode like NONE when my nettcpbinding is set in c# code on the client side and on the server my binding is defined in the app.config? How can I change the server`s app.config from the client?
WCF server endpoint:
<service name="Test.ServiceProvider.MyService">
<endpoint address="" binding="netTcpBinding" contract="Test.Contracts.IMyService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexTcpBinding" name="NetTcpMetadataPoint"
contract="IMetadataExchange">
</endpoint>
</service>
WCF client endpoint:
the Uri is:
net.tcp//localhost:12345/MyService
1.) What else should my 2nd address be for the 2nd NetTcpBinding?
I guess I just change the MyService to MyEncryptedService and use the same interface? But then I have 2 equal classes/implementations of one interface. Thats stupid actually.
2.) How does the client binding find its server binding?
In short you can’t. The server exposes the service and the server dictates its security settings. It will either require security or not but this configuration is done when the server starts hosting of the service and cannot be changed without “stopping” the service. The only way to change it from the client is through some “administration” which will change configuration of the service and restart it but this will have global scope.
If you need both secured and unsecured communication you need to expose two different endpoints. One for secured operations and one for unsecured (if operations on both endpoints are different you should also use different service contracts).