WCF自我寄宿方案,在局域网中不灵,求大大指点
自我寄宿WinForm上的WCF服务,本机测试顺利: 服务器-客户端在同机运行可是局域网中搞不定,客户端访问不到服务器,请大神们帮帮忙
附: 公网上是可以的,把服务器.exe放到公网上运行 客户端可以用公网IP访问
服务器.exe:
ServiceHost host = new ServiceHost(typeof(XXX));
BasicHttpBinding binding = new BasicHttpBinding();
string address = "http://" + localIP + ":8123/ABC"; //localIP是局域网IP
host.AddServiceEndpoint(typeof(IXXX), binding, address);
host.Open();
客户端.exe:
string remote = "http://localhost:8123/ABC"; //异机测试时,localhost用对方的局域IP替换
EndpointAddress address = new EndpointAddress(remote);
ChannelFactory<IXXX> channel = new ChannelFactory<IXXX>(binding, address);
IXXX proxy = channel.CreateChannel();
proxy.TEST(...)