Wcf Facility使用net.tcp

时间:2011-05-15 09:50:06

标签: c# wcf castle-windsor

我正在尝试配置我的WCF服务以使用net.tcp或netnamedpipes。

这是我的容器配置(我已经注释掉了现有的http绑定):

        var metadata = new ServiceMetadataBehavior
        {
            HttpGetEnabled = true
        };

        var debug = new ServiceDebugBehavior
        {
            IncludeExceptionDetailInFaults = true
        };

        container.AddFacility<WcfFacility>(f => f.Services.AspNetCompatibility =
                                           AspNetCompatibilityRequirementsMode.Required)
            .Install(Configuration.FromAppConfig())
            .Register(
                Component.For<IServiceBehavior>().Instance(metadata),
                Component.For<IServiceBehavior>().Instance(debug),
                Component
                    .For<IAccountService>()
                    .ImplementedBy<AccountService>()
                    .Named("SomeCompany.Services.Account.AccountService")
                    .LifeStyle.Transient
                    .ActAs(new DefaultServiceModel().Hosted().AddEndpoints(
                                   //WcfEndpoint.BoundTo(new BasicHttpBinding { MaxReceivedMessageSize = int.MaxValue }),
                                   //WcfEndpoint.BoundTo(new WSHttpBinding(SecurityMode.None) { MaxReceivedMessageSize = int.MaxValue }).At("ws"),
                                   WcfEndpoint.BoundTo(new NetTcpBinding()).At("net.tcp://localhost/Account") 
                               )),
                Component
                    .For<IAccountNetworkService>()
                    .ImplementedBy<AccountNetworkService>()
                    .Named("SomeCompany.Services.Account.AccountNetworkService")
                    .LifeStyle.Transient
                    .ActAs(new DefaultServiceModel().Hosted()
                               .AddEndpoints(
                                   WcfEndpoint.BoundTo(new BasicHttpBinding { MaxReceivedMessageSize = int.MaxValue }),
                                   WcfEndpoint.BoundTo(new WSHttpBinding(SecurityMode.None) { MaxReceivedMessageSize = int.MaxValue }).At("ws")
                               ))
           );

我的客户有以下内容:

<endpoint address="net.tcp://localhost/Account" binding="netTcpBinding" contract="SomeCompany.Services.Account.Contracts.IAccountService" name="accountServiceClient"></endpoint>

当我尝试访问该服务时,我得到以下内容:

No connection could be made because the target machine actively refused it 127.0.0.1:808

我也尝试过这个wiki底部的建议:

http://docs.castleproject.org/(S(hv034j45ln0cgt2zkpl1nce5))/Windsor.WCF-Facility-Registration.ashx

我错过了一些明目张胆的事吗?

1 个答案:

答案 0 :(得分:0)

嗨,看起来像防火墙问题类似的事情发生在我的Windows防火墙提示我的应用程序的权限,我点击取消而不是确定。请尝试禁用Windows防火墙并检查错误是否仍然存在。

另一个可能的问题是您用于绑定的安全性。尝试在服务器和客户端的绑定配置中添加以下节点。