WCF Discovery UDPEndpoint 在 IIS 上发布后不起作用
WCF Discovery UDPEndpoint did not work after published on IIS
我用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端口。有什么办法可以解决这个问题吗?
看来我的要求达到了。我在我的服务端配置防火墙。 Windows 高级安全防火墙->入站规则->新规则->端口->UDP->所有本地端口->允许连接->域,私有,Public->此规则的名称.但是我不确定为什么需要这个,我的应用程序已经在防火墙中配置了 Udp 协议。
我用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端口。有什么办法可以解决这个问题吗?
看来我的要求达到了。我在我的服务端配置防火墙。 Windows 高级安全防火墙->入站规则->新规则->端口->UDP->所有本地端口->允许连接->域,私有,Public->此规则的名称.但是我不确定为什么需要这个,我的应用程序已经在防火墙中配置了 Udp 协议。