0

WCFでDiscoveryEndpointsを使用していますが、サービスが検出され、DiscoveryEndpointに接続すると、実際にサービスのインスタンスが作成されることに気付きました。これいらない。

これは、(StructureMapをサポートするために)カスタムインスタンスプロバイダーを使用しているという事実にほぼ確実に関連しています。これは、各EndpointDispatcherにカスタムInstanceProviderを適用します。

コントラクトが実際にサービスの実装と一致するエンドポイントにのみカスタムInstanceProviderを適用したいようです。

何か案は?

4

1 に答える 1

1

私はそれを解決したと思います...私はIsSystemEndpointが設定されているものを無視しています:

    public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
    {
        foreach (ChannelDispatcherBase cdb in serviceHostBase.ChannelDispatchers)
        {
            ChannelDispatcher cd = cdb as ChannelDispatcher;
            if (cd != null)
            {
                foreach (EndpointDispatcher ed in cd.Endpoints)
                {
                    if (!ed.IsSystemEndpoint) // Ignore MEX etc
                        ed.DispatchRuntime.InstanceProvider =
                            new StructureMapInstanceProvider(serviceDescription.ServiceType);
                }
            }
        }
    }
于 2010-12-10T07:32:00.217 に答える