我试图做一个Web服务发现使用WCF的DiscoveryClient
使用此代码:WCF的Web服务发现解决
// Setup the discovery client (WSDiscovery April 2005)
DiscoveryEndpoint discoveryEndpoint = new UdpDiscoveryEndpoint(DiscoveryVersion.WSDiscoveryApril2005);
DiscoveryClient discoveryClient = new DiscoveryClient(discoveryEndpoint);
// Setup the wanted device criteria
FindCriteria criteria = new FindCriteria();
criteria.ScopeMatchBy = new Uri("http://schemas.xmlsoap.org/ws/2005/04/discovery/rfc3986");
criteria.Scopes.Add(new Uri("onvif://www.onvif.org/"));
// Go find!
criteria.Duration = TimeSpan.FromMilliseconds(duration);
discoveryClient.FindAsync(criteria, this);
这工作得很好的机器上使用单一IP地址( 10.1.4.25)分配给单个网络接口。广播从10.1.4.25发送到239.255.255.250,并且我从同一子网上的5个设备获得响应。
但是,当机器在同一接口上有多个IP时,它似乎会选择一个源IP并从中发送请求。 在这种情况下,我从单个设备获得169.254地址的回复。
我试过将UdpDiscoveryEndpoint.TransportSettings.MulticastInterfaceId
设置为一个合适的接口ID,它没有帮助,因为它识别单个接口,而不是特定的IP。 UdpDiscoveryEndpoint.ListenUri
属性也返回多播地址,所以不会影响源IP。 UdpDiscoveryEndpoint.Address
是发现协议的URN。
有什么办法可以强制它从特定的IP地址发送,或理想情况下,在每个配置的IP上发送多个请求?我也尝试过ONVIF Device Manager,似乎有同样的问题。
请注意,这不是关于将服务绑定到特定的或“所有地址”IP。它是关于发送发现请求的IP。
[本页](http://msdn.microsoft.com/en-us/library/bb706924.aspx#LinkTarget_1973)提到设置'/秒:信封/秒:页眉/一个:ReplyTo'地址,但我不确定这可以在WCF中设置。 – Deanna
你有没有解决过这个问题?我遇到同样的问题 – HypeZ
@HypeZ Nope,这仍然是一个问题。 – Deanna