WCF引用 代码

扫码查看

方法1:

            using (ChannelFactory<ICommonService> channelFactory = new ChannelFactory<ICommonService>(new BasicHttpBinding(), "http://127.0.0.1/SystemSecurityService.svc"))
{
ICommonService proxy = channelFactory.CreateChannel();
return proxy;
}

方法2:

            BasicHttpsBinding BINDING = new BasicHttpsBinding();
return new Service1Client(BINDING, new EndpointAddress("http://127.0.0.1/Service1.svc"));//构建WCF客户端实例

方法3:

            WSHttpBinding BINDING = new WSHttpBinding();
SoapClientConfig.ReadBindingConfig(BINDING, "WSHttpBinding_ICommonService");//从配置文件(app.config)读取配置。
string endpoint = SoapClientConfig.GetSoapRemoteAddress("WSHttpBinding_ICommonService");
return new CommonServiceClient(BINDING, new EndpointAddress(endpoint));//构建WCF客户端实例.
05-28 14:00
查看更多