私は3つのアセンブリを作成しました。 Webサイト、WCFサービス、およびサービスが実装するインターフェイスを保持するコントラクトアセンブリ。 Castle Windsorを使用してクライアント(Webサイト)上で私のためのサービスを作成し、私が使用したい各サービスのWebサイトのWeb.configにエンドポイントを持つ必要はありません。Castle Windsor WcfFacilityを使用してクライアントエンドポイントを作成する
私は、契約アセンブリを見て、ネームスペース内のすべてのサービスインターフェイスを取得したいと考えています。今のところサービスごとに、コンテナにコンポーネントを登録するときに次のようなことがあります。
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は素晴らしいですが、ドコは少し欠けています...
のように動作します魅力、ありがとうございました。 –
これは何をしますか? (f => f.CloseTimeout = TimeSpan.Zero) –
これは、すべてのサービスのデフォルトのクローズタイムアウトを設定します。これは、「クローズ操作が完了するまでの時間間隔を指定するTimeSpan値です。ゼロに等しい。デフォルトは00:01:00である。 - http://msdn.microsoft.com/en-us/library/ms731361.aspxから。また、ここにはすべての可能なタイムアウトについての良いスレッドがあります。http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/84551e45-19a2-4d0d-bcc0-516a4041943d/ – kmp