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