【发布时间】:2009-12-30 07:48:17
【问题描述】:
如何在客户端站点中以编程方式更改端点地址?
【问题讨论】:
标签: wcf
如何在客户端站点中以编程方式更改端点地址?
【问题讨论】:
标签: wcf
proxy.Endpoint.Address = new EndpointAddress("http://newaddress");
其中proxy 是导入WSDL 时生成的客户端类的实例。或者您可以在创建客户端代理时指定地址:
var endpoint = new EndpointAddress("http://newaddress");
var proxy = new SomeClientProxy("BasicHttpBinding_IHelloWorld", endpoint);
【讨论】:
http://deadkota.wordpress.com/2010/06/23/wcf-client-change-endpoint-address-dynamically/
using(abcServiceClient proxy = new ABCServiceClient())
{
proxy.Endpoint.Address = new System.ServiceModel.EndpointAddress("net.tcp://localhost:8082/ABCService");
proxy.Open();
proxy.Function();
}
【讨论】: