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

发布于 2024-12-13 14:00:06 字数 656 浏览 0 评论 0原文

我对城堡 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()
    )
);

I am confused about the castle wcf facility registration.

I read some blog posts for BasicHttpBinding.
But could not find a clear easy sample to setup a net.tcp setup.

I want to host the service from a console application...

I wrote something like this... can you see a problem here?

_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()
    )
);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

烟─花易冷 2024-12-20 14:00:06

如果您希望发布元数据,则需要启用端口共享(让 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()
    )
);

使用 castle Windsor 3.0 可以正常工作。

If you wish to publish metadata you will need to enable port sharing (to let the MEX endpoint share the same port as the regular TCP port - you'll get an AddressAlreadyInUse exception if you have this set to false) and you probably need to specify a port on your URL (not sure what port TCP would use otherwise), so your code should be (assuming port 8080 is OK for you):

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

This works fine using castle windsor 3.0.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文