自分の WCF プロジェクトで Castle WCF 統合機能を使用しようとしていますが、道に迷ってしまいました。助けてもらえますか?
したがって、ここに状況があります:
TCP 経由の Windows サービス内でホストされている WCF サービス ライブラリがあります。以下は、私の WCF Service Library にあるものです: Service Impl:
[ServiceContract]
public interface ICalculatorService
{
[OperationContract]
int Add(int x, int y);
}
public class CalculatorService : ICalculatorService
{
public int Add(int x, int y)
{
return x + y;
}
}
構成:
<system.serviceModel>
<services>
<service name="namespace.CalculatorService">
<endpoint address="" binding="netTcpBinding" bindingConfiguration=""
contract="namespace.iCalculatorService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexTcpBinding" bindingConfiguration=""
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8732/CalculatorService/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
コンテナー構成これは WCF プロジェクト内にあり、すべてをキャッスルに登録しました (WCF サービスから登録する必要があるのか、WCF サービスをホストする Windows サービスから登録する必要があるのか 、wcf 機能をどこに登録する必要があるのか わかりません)。
public class ConfigureContainerCastle
{
private readonly IWindsorContainer container;
public ConfigureContainerCastle(IWindsorContainer container)
{
this.container = container;
}
public void Configure()
{
// Any component registration.
container.Register(Component.For<ICalculatorService>().ImplementedBy<CalculatorService>());
//All other component registration.
}
}
以下は、私のWindowsサービスにあるものです:
public class Host<T>:ServiceBase
{
private ServiceHost serviceHost = null;
protected override void OnStart(string[] args)
{
if (serviceHost != null)
{
serviceHost.Close();
}
// How do I call the DefaultServiceHostFactory and start the service?
// Should I call the WCF facility from here or from WCF service library?
// var container = new WindsorContainer();
// var configureContainer = new DataServicesConfigureContainer(container);
// var hostFactory = new DefaultServiceHostFactory(container.Kernel);
serviceHost = new ServiceHost(typeof (T));
serviceHost.Open();
}
protected override void OnStop()
{
if (serviceHost == null)
return;
serviceHost.Close();
serviceHost = null;
}
}
そして、Windows サービスの構成 (app.config) は、文字通り行ごとに WCF サービスと同じです。
問題は、これを WCF 機能と一緒に配線するにはどうすればよいかということです。http と global.asax を使用した多くの例を見てきましたが、Windows サービスの例はありません。助けていただけますか?それへの適切なリンクでさえ役に立ちます。
ありがとう -マイク