具有多个服务合同发现的WCF单个端点

时间:2015-02-26 11:04:44

标签: c# wcf service-discovery

我使用具有多个服务合同的单个端点。例如:

在界面装配中:

public interface IServer1 { ... }

public interface IServer2 { ... }

在服务器程序集中:

internal interface IServer : IServer1, IServer2 {}

internal class Server : IServer
{
    ...
    var host = new ServiceHost(this);
    host.AddServiceEndpoint(typeof(IServer), ...);
    host.Description.Behaviors.Add(new ServiceDiscoveryBehavior());
    host.AddServiceEndpoint(new UdpDiscoveryEndpoint());
    ...
}

在客户端程序集中:

internal class Client1
{
    ...
    var factory = new ChannelFactory<IServer1>(...);
    ...
}

internal class Client2
{
    ...
    var factory = new ChannelFactory<IServer2>(...);
    ...
}

除服务发现案例外,它的工作正常:

var discovery = new DiscoveryClient(new UdpDiscoveryEndpoint());
discovery.Find(new FindCriteria(typeof(IServer1)); // Not found
discovery.Find(new FindCriteria(typeof(IServer2)); // Not found

有没有办法在不暴露IServer的情况下发现IServer1和IServer2?

0 个答案:

没有答案