3 つのアセンブリを作成しました。Web サイト、WCF サービス、およびサービスが実装するインターフェイスを保持するコントラクト アセンブリ。Castle Windsor を使用してクライアント (Web サイト) でサービスを作成し、使用するサービスごとに Web サイトの web.config にエンドポイントを設定する必要がないようにしたいと考えています。
コントラクト アセンブリを見て、名前空間内のすべてのサービス インターフェイスを取得したいと考えています。現在、すべてのサービスについて、コンポーネントをコンテナに登録するときに次のようなものがあります。
container.Register(Component.For<ChannelFactory<IMyService>>().DependsOn(new { endpointConfigurationName = "MyServiceEndpoint" }).LifeStyle.Singleton);
container.Register(Component.For<IMyService>().UsingFactoryMethod((kernel, creationContext) => kernel.Resolve<ChannelFactory<IMyService>>().CreateChannel()).LifeStyle.PerWebRequest);
私のweb.configにはセットアップコードがあります。
<system.serviceModel>
<extensions>
<behaviorExtensions>
<add name="AuthToken" type="MyNamespace.Infrastructure.AuthTokenBehavior, MyNamespace.Contracts" />
</behaviorExtensions>
</extensions>
<behaviors>
<endpointBehaviors>
<behavior>
<AuthToken />
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<wsHttpBinding>
<binding maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00">
<readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647"></readerQuotas>
<security mode="None" />
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint name="MyServiceEndpoint" address="http://someurl/MyService.svc" binding="wsHttpBinding" contract="MyNamespace.Contracts.IMyService"></endpoint>
</client>
</system.serviceModel>
結局、ほとんど同じように見える複数のサービス エンドポイントができてしまい、クライアント マシンに展開するときに、ベース URL がすべて同じであっても、すべてのエンドポイントのアドレスを設定する必要があります。
コードを介して取得した web.config にベース URL を設定し、コントラクト アセンブリのリフレクションを使用してサービスをコンテナーに登録したいと考えています。上記の構成ファイルにある特殊なエンドポイントの動作が必要です。
どこから始めますか?WcfFacility は良さそうですが、ドコはちょっと物足りない…