WCF 发现根本不起作用 [英] WCF Discovery simply doesn't work
问题描述
我正在尝试将临时发现添加到简单的 WCF 服务客户端设置(目前通过控制台应用程序中的自托管实现).在 Windows 7 上使用 VS2010 进行调试,并执行我在在线教程中可以找到的任何内容,但仍然 - 发现客户端根本找不到任何东西.不用说,如果我打开一个客户端到正确的服务端点,我可以从客户端访问该服务.
I'm trying to add ad-hoc discovery to a simple WCF service-client setup (currently implemented by self hosting in a console app). Debugging using VS2010 on windows 7, and doing whatever I can find in online tutorial, but still - the discovery client simply finds nothing. Needless to say if I open a client to the correct service endpoint I can access the service from the client.
服务代码:
using (var selfHost = new ServiceHost(typeof(Renderer)))
{
try
{
selfHost.Open();
...
selfHost.Close();
服务 app.config:
service app.config:
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<services>
<service name="TestApp.Renderer">
<host>
<baseAddresses>
<add baseAddress="http://localhost:9000" />
</baseAddresses>
</host>
<endpoint address="ws" binding="wsHttpBinding" contract="TestApp.IRenderer"/>
<endpoint kind="udpDiscoveryEndpoint"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceDiscovery/>
<serviceMetadata httpGetEnabled="True"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
客户端发现代码:
DiscoveryClient discoveryClient = new DiscoveryClient(new UdpDiscoveryEndpoint());
var criteria = new FindCriteria(typeof(IRenderer)) { Duration = TimeSpan.FromSeconds(5) };
var endpoints = discoveryClient.Find(criteria).Endpoints;
端点"集合总是空的.我已经尝试从调试器、命令行、管理命令行运行服务和客户端 - 一切,但无济于事(当然,所有这些都在本地机器上,不是说我需要它运行我的整个子网最终)
The 'endpoints' collection always comes out empty. I've tried running the service and client from the debugger, from a command line, from an admin command line - everything, but to no avail (all on the local machine, of course, not to mantion I'll need it running on my entire subnet eventually)
任何帮助将不胜感激:-)
Any help would be appreciated :-)
推荐答案
该死!是防火墙...出于某种原因,所有 UDP 通信都被阻止了 - 禁用防火墙解决了问题.现在我只需要弄清楚正确的防火墙配置...
Damn! it was the firewall... for some reason all UDP communication was blocked - disabling the firewall solved the problem. Now I only need to figure out the correct firewall configuration...
这篇关于WCF 发现根本不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!