【问题标题】:WCF Discovery UDPEndpoint did not work after published on IISWCF 发现 UDPEndpoint 在 IIS 上发布后不起作用
【发布时间】:2016-06-24 09:31:57
【问题描述】:

我用WCF Discovery UDPEndpoint做了一个测试,它在我自己的电脑上运行,但是如果我将它发布到IIS,然后从其他电脑调用它,它就找不到了。

我已经用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 端口。有没有办法解决这个问题?

【问题讨论】:

    标签: c# wcf discovery ws-discovery


    【解决方案1】:

    看来我已经达到了我的要求。我在我的服务端配置防火墙。具有高级安全性的 Windows 防火墙->入站规则->新规则->端口->UDP->所有本地端口->允许连接->域、私有、公共->此规则的名称。但我不确定为什么需要这个,我的应用程序已经在防火墙中配置了 Udp 协议。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-04-28
      • 1970-01-01
      • 2020-11-01
      • 1970-01-01
      • 2018-02-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多