C#ServiceHost似乎忽略了VM中主机的连接

时间:2016-12-14 20:11:54

标签: c# wcf wsdl

我已经从WSDL实现了一个非常基本的服务,我使用ServiceHost对象提供它,它似乎在本地工作。我用服务的代码是:

static void Main(string[] args)
    {
        Uri httpUri = new Uri("http://192.168.18.1:8080/");

        using (ServiceHost hService = new ServiceHost(typeof(TritonClientClient), httpUri))
        {
            // hService.AddServiceEndpoint(typeof(ITritonClient), new BasicHttpBinding(), "http://localhost:8000/BasicService");                

            hService.Open();

            Console.WriteLine("Listening. Press any key to close...");
            Console.ReadLine();
            Console.WriteLine("Closing...");

            hService.Close();
        }
    }

它似乎在本地工作,因为我可以浏览到http://192.168.18.1:8080/?wsdl并获得服务描述文件。

问题是我需要从虚拟机(使用VMware)访问此服务。该机器配置为只有一个主机"网络适​​配器,我可以从客户端反向主机,反之亦然。但是,我无法直接从主机访问该服务。

在主机中使用Wireshark我可以看到guest虚拟机尝试启动TCP握手,但没有人回答:

Wireshark capture

为了记录,主机的IP是192.168.18.1,客户的IP是192.168.18.128。我在ServiceHost中有什么需要做的,所以它回应了VM的请求吗?

1 个答案:

答案 0 :(得分:1)

确保您的防火墙设置不会阻止主机上的端口8080。