1

我使用 WSHttpBinding 创建了 WCF 服务:

ServiceHost svh = new ServiceHost(typeof(MyService));
var httpLocation = "http://" + address + ":4041";
svh.AddServiceEndpoint(typeof(IMyService), new WSHttpBinding(SecurityMode.None), httpLocation);
svh.Open();

我已经在系统中注册了

netsh http add urlacl url=http://+:4041/ user=username

当我尝试从 localhost 连接到它时,该服务可以正常工作。

但是当我把它放在另一台电脑上时(地址='localhost'或地址='ip-of-the-machine'),连接失败,出现以下异常:

There was no endpoint listening at http://192.168.44.128:4041/ that could accept 
the message. This is often caused by an incorrect address or SOAP action. See 
InnerException, if present, for more details.

内部异常:

A connection attempt failed because the connected party did not properly respond 
after a period of time, or established connection failed because connected host
has failed to respond 192.168.44.128:4041

我尝试将服务添加到防火墙,但没有帮助。

这里有什么问题?

更新

以下是来自 的相关条目netstat -ano。第一个是 http 端点,不能从外部连接,第二个是 net.tcp 端点,可以正常工作:

TCP    [::]:4041              [::]:0                 LISTENING       4
TCP    192.168.44.128:9939    0.0.0.0:0              LISTENING       2120
4

1 回答 1

1

在命令行提示符下使用“NETSTAT -ano”验证您的服务正在侦听指定端口。选中后,请尝试从客户端框中 PING 您的服务框 IP。如果两者都成功,您很可能正在查看防火墙和/或网络交换机配置问题。

于 2013-01-18T22:22:47.237 回答