我想从web.config或app.config中获取Binding对象。WCF:如何从配置中获取绑定对象
因此,此代码的工作:
wcfTestClient = new TestServiceClient("my_endpoint", Url + "/TestService.svc");
,但我想做到以下几点:
Binding binding = DoSomething();
wcfTestClient = new TestServiceClient(binding, Url + "/TestService.svc");
我感兴趣的DoSomething的()方法,当然。
仅当您知道要使用何种绑定时, WSHttpBinding或NetTcpBiding。您失去了在运行时更改绑定种类的灵活性。 – Anthony 2009-10-15 12:51:03
但我需要任何绑定,不仅(WSHttpBinding) – 2012-12-26 11:12:03
对于自定义绑定:var binding = new System.ServiceModel.Channels.CustomBinding(“BindingName”); – Sal 2017-01-12 16:58:46