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客户端实例.

 

posted on 2017-07-08 22:41  _ali  阅读(198)  评论(0编辑  收藏  举报

导航