我已經創建了三個組件的客戶端的端點。一個網站,一個WCF服務和一個合約程序集,它們包含了服務實現的接口。我想用溫莎城堡到客戶(網站)上創建爲我服務,讓我不必在網站進行,我希望使用的每個服務的web.config文件的端點。使用溫莎城堡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看起來不錯,但是DOCO有點欠缺...
這就像一個魅力,非常感謝。 – 2012-04-12 01:25:19
這是幹什麼的? (f => f.CloseTimeout = TimeSpan.Zero) – 2012-04-12 01:36:28
設置所有服務的默認closetimeout - 這是「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 2012-04-12 06:38:11