我是否需要svc文件来为非HTTP服务设置Castle Wcf Facility

时间:2011-11-03 21:08:10

标签: wcf castle-windsor castle net.tcp wcffacility

我对城堡wcf设施注册感到困惑。

我阅读了一些关于BasicHttpBinding的博客文章。 但是找不到一个简单易用的样本来设置net.tcp设置。

我想从控制台应用程序托管服务......

我写了这样的话......你能在这里看到问题吗?

_container = new WindsorContainer();
_container.AddFacility<WcfFacility>();

_container.Register(Component.For<IMembershipService>().ImplementedBy<MembershipService>()
    .AsWcfService(
        new DefaultServiceModel()
            .AddEndpoints(WcfEndpoint
                    .BoundTo(new NetTcpBinding() { PortSharingEnabled = false })
                    .At("net.tcp://localhost/MembershipService")
            )
            .PublishMetadata()
    )
);

1 个答案:

答案 0 :(得分:4)

如果您希望发布元数据,则需要启用端口共享(让MEX端点与常规TCP端口共享同一端口 - 如果将此设置为false,则会获得AddressAlreadyInUse异常)并且您可能需要需要在你的URL上指定一个端口(不知道TCP会使用哪个端口),所以你的代码应该是(假设端口8080对你来说还可以):

_container.Register(Component.For<IMembershipService>().ImplementedBy<MembershipService>()
    .AsWcfService(
        new DefaultServiceModel()
            .AddEndpoints(WcfEndpoint
                    .BoundTo(new NetTcpBinding() { PortSharingEnabled = true})
                    .At("net.tcp://localhost:8080/MembershipService")
            )
            .PublishMetadata()
    )
);

使用城堡windsor 3.0可以正常使用。