C# 如何在代码中更新客户端端点绑定
我有一个关于在代码中修改客户端端点绑定的问题。 我添加了一个web服务引用,并为其创建了一个客户端端点绑定。 在web.config中,我将绑定集设置为基本https,我希望将其更改为ex.http,这是我在web.config中以“basicHttpBinding”的名称指定的。当我创建web服务引用的实例时,无法使用地址和绑定,因为没有接受此类参数的构造函数C# 如何在代码中更新客户端端点绑定,c#,web-services,binding,web-config,C#,Web Services,Binding,Web Config,我有一个关于在代码中修改客户端端点绑定的问题。 我添加了一个web服务引用,并为其创建了一个客户端端点绑定。 在web.config中,我将绑定集设置为基本https,我希望将其更改为ex.http,这是我在web.config中以“basicHttpBinding”的名称指定的。当我创建web服务引用的实例时,无法使用地址和绑定,因为没有接受此类参数的构造函数 <endpoint address="http://localhost/LocalService/SendRequest.a
<endpoint address="http://localhost/LocalService/SendRequest.asmx"
binding="basicHttpsBinding" bindingConfiguration="basicHttpsBinding"
contract="LocalService.SendRequest" name="LocalServiceClient" />
任何关于如何解决这个问题的建议都将不胜感激
干杯 如果我理解正确,这就是您要寻找的:
var x = new ServiceClient();
x.Endpoint.Binding = new BasicHttpBinding("optional configuration name");
var binding = new System.ServiceModel.BasicHttpBinding() { Name = "LocalServiceClient", Namespace = "LocalService.SendRequest" };
var endPoint = new System.ServiceModel.EndpointAddress("http://localhost/LocalService/SendRequest.asmx");
var client = new ServiceClient(binding, endPoint);