如何在客户端站点中以编程方式更改端点地址?

时间:2009-12-30 07:48:17

标签: wcf

如何在客户端站点中以编程方式更改端点地址?

2 个答案:

答案 0 :(得分:8)

proxy.Endpoint.Address = new EndpointAddress("http://newaddress");

其中proxy是导入WSDL时生成的客户端类的实例。或者您可以在创建客户端代理时指定地址:

var endpoint = new EndpointAddress("http://newaddress");
var proxy = new SomeClientProxy("BasicHttpBinding_IHelloWorld", endpoint);

答案 1 :(得分:-1)

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