WCF Discovery Udpendpoint在IIS上发布后不起作用



我用wcf discovure udpendpoint进行了测试,它可以在我自己的计算机上工作,但是如果我将其发布给IIS,然后从其他计算机中调用它,找不到。<<<<<<<<<。/p>

我已经使用IP。

设置了地址

服务

using (ServiceHost host = new ServiceHost(typeof(DiscoveryProxy), new Uri("http://xx.xxxx.xxx.xxx:8080/DiscoveryProxy")))
{
    ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
    smb.HttpGetEnabled = true;
    host.Description.Behaviors.Add(smb);
    ServiceEndpoint sep= host.AddServiceEndpoint(typeof(IDiscoveryProxy),new BasicHttpBinding(),"");
    sep.ListenUri = new Uri("http://xx.xxxx.xxx.xxx:8080/DiscoveryProxy/via");
    ServiceDiscoveryBehavior sdb = new ServiceDiscoveryBehavior();
    sdb.AnnouncementEndpoints.Add(new UdpAnnouncementEndpoint());
    host.Description.Behaviors.Add(sdb);
    host.AddServiceEndpoint(new UdpDiscoveryEndpoint());
    host.Open();
    Console.WriteLine("service is open");
    Console.ReadLine();
    host.Close();
}

在客户端正确添加了服务参考,我可以从IE浏览服务。但这不能由UDP发现。

客户

    DiscoveryClient client = new DiscoveryClient(new UdpDiscoveryEndpoint());
    FindResponse response = client.Find(new FindCriteria(typeof(myDiscoveryProxy)));
    if (response.Endpoints.Count > 0)
    {
        EndpointAddress address = response.Endpoints[0].Address;
        Console.WriteLine("service address is " + address);
        ServiceReference2.myDiscoveryProxyClient service = new ServiceReference2.myDiscoveryProxyClient(new BasicHttpBinding(), address);
        service.getString("discovery proxy");
    }

我已经在客户端和服务中打开了UDP端口。有什么方法可以解决此问题?

看来我已经达到了要求。我在服务方面配置防火墙。Windows防火墙带有高级安全性 -> Inbound Rules->新规则 -> port-> udp->所有本地端口 ->允许连接 ->域,私有,public,> public->名称。但是我不确定为什么我需要这个,我的应用程序已经在防火墙中配置了UDP协议。

最新更新