我该如何在客户端编程中以程序方式更改终结点地址?
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();
}