如果不添加引用或代理类,则无法使用WCF服务

时间:2017-12-01 11:07:25

标签: c# .net wcf

我应该使用托管在服务器上的wcf服务。我的网络无法访问此wcf服务。由于我无法访问wcf,因此我无法添加服务引用并在visual studio中自动创建代理类。我希望我可以编写代码来访问这项服务(即使我实际上无法在我的网络上访问它),然后将其部署到可以访问wcf的服务器上。就像我在web api的情况下一样。

我在推荐这个教程:https://www.aspsnippets.com/Articles/Call-Consume-WCF-Service-SVC-without-creating-Proxy-in-ASPNet.aspx

        private IService GetServiceClient()
        {
            BasicHttpBinding binding = new BasicHttpBinding();
            EndpointAddress endpoint = new    
            EndpointAddress("http://localhost:8732/Design_Time_Addresses/WCF_NewsService/News_Service/");
            IService client = ChannelFactory<IService>.CreateChannel(binding, endpoint);
            return client;
        }

我从哪里获取IService?我很迷惑。我所拥有的是一个我无法访问的URL。并且我应该使用wcf中的方法string GetCustomer(string name)

0 个答案:

没有答案