Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在代码中更新客户端端点绑定_C#_Web Services_Binding_Web Config - Fatal编程技术网

C# 如何在代码中更新客户端端点绑定

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

我有一个关于在代码中修改客户端端点绑定的问题。 我添加了一个web服务引用,并为其创建了一个客户端端点绑定。 在web.config中,我将绑定集设置为基本https,我希望将其更改为ex.http,这是我在web.config中以“basicHttpBinding”的名称指定的。当我创建web服务引用的实例时,无法使用地址和绑定,因为没有接受此类参数的构造函数

  <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);