城堡WCF设施容器配置 [英] Castle WCF facility Container Configuration

查看:140
本文介绍了城堡WCF设施容器配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在与温莎城堡提供的WCF设施真正的麻烦。我没有找到适当的文件可能指向我的一些例子与WCF基金的当前版本

I'm having real trouble with the WCF Facility provided by Castle Windsor. I'm not finding appropriate documentation which could point me to some examples with the current version of WCF Facility.

以下是我的情况:我想写一个WCF服务,暴露在TCP将由Windows服务进行托管。

Following is my scenario: I want to write a WCF service, exposed over TCP which will be hosted by a Windows Service.

我爱上短的如何配置WCF设施,在那里配置它是否应该在WCF服务或Windows服务主机。

I'm falling short of how to configure the WCF facility, where to configure it whether it should be in the WCF service or in the windows service host.

此外我将如何配置WCF设施时,我的服务端点的WCF的配置文件中声明?

Also how would I configure the WCF facility when my service end points are declared in the WCF config file?

可有人请帮忙吗?链接将不胜感激,但我找不到了。

Can someone please help? A link would be much appreciated, although I could not find much.

推荐答案

这是设置的一个例子/步行通过一(人为)服务。

This is an example/walk-through of setting up a (contrived) service.

有关我的例子中,有一个服务合同WindsorWCF.IMyService和一个名为WindsorWCF.MyService服务。我选择与应用中配置TCP端点配置服务如下:

For my example, there is a service contract WindsorWCF.IMyService and a service called WindsorWCF.MyService. I've chosen to configure the service with a TCP endpoint in the app config as follows:

<system.serviceModel>
  <services>
    <service name="WindsorWCF.MyService">
      <endpoint name ="IMyService_Endpoint" address="net.tcp://localhost:9876/MyService" binding="netTcpBinding" contract="WindsorWCF.IMyService" />
    </service>
  </services>
</system.serviceModel>



接着,添加一个窗口配置(XML)文件到您的服务项目,将组件添加到它

Next, add an Window config (XML) file to your service project, and add a component to it:

<configuration>
  <components>
    <component id="MyService" service="WindsorWCF.IMyService, WindsorWCF" type="WindsorWCF.MyService, WindsorWCF" />
  </components>
</configuration>

在服务宿主应用程序本身,我已经添加以下代码(我用时一个控制台应用程序我写的代码,但这个想法是一样的):

In the service host application itself, I've added the following code (I used a console application when I wrote the code, but the idea is the same):

static void Main(string[] args)
{
    InitWindsor();
    var host = new DefaultServiceHostFactory().CreateServiceHost("MyService", new Uri[0]);
    host.Open();
    Console.ReadLine();
}

static IWindsorContainer Container { get; set; }
private static void InitWindsor ()
{
    Container = new WindsorContainer().AddFacility<WcfFacility>().Install(Configuration.FromXmlFile("windsor.config"));
}

这是它的例子 - 我相信这是有道理的。

That's it for the example - I trust it makes sense.

这篇关于城堡WCF设施容器配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆