使用Windsor创建WCF服务时出现问题

时间:2010-06-02 13:49:56

标签: wcf castle-windsor

有人知道如何在IIS 7.0上使用Windsor配置WCF吗?我正在使用WCF Windsor工厂主干和Windsor 2.1.1的最新产品。 http://www.castleproject.org/container/facilities/trunk/wcf/index.html上的示例已过期。甚至WCF工具中的演示项目也没有提到如何使用配置在IIS中设置WCF服务,我找不到任何可以使用web.config的system.serviceModel部分甚至通过代码在服务器端设置WCF的示例。当我使用下面的代码时,它总是创建basicHttpBinding,我无法弄清楚如何设置不同的绑定。

protected void Application_Start(object sender, EventArgs e)
{
    var returnFaults = new ServiceDebugBehavior
                           {
                               IncludeExceptionDetailInFaults = true,
                               HttpHelpPageEnabled = true
                           };

    var metadata = new ServiceMetadataBehavior {HttpGetEnabled = true};

    container = new WindsorContainer()
        .AddFacility<WcfFacility>()
        .Register(
            Component.For<IServiceBehavior>().Instance(returnFaults),
            Component.For<IServiceBehavior>().Instance(metadata),
            Component.For<IMyService>()
                     .Named("MyService")
                     .ImplementedBy<MyService>()
                     .LifeStyle.Transient
            );
}

这是MyService.svc

<%@ ServiceHost Language="C#" Debug="true" Service="MyService" 
                Factory="Castle.Facilities.WcfIntegration.DefaultServiceHostFactory, Castle.Facilities.WcfIntegration" %>

1 个答案:

答案 0 :(得分:3)

我最近写了blog post about Windsor's WCF Facility。请务必阅读评论,因为它们包括涉及温莎的一个活跃提交者的讨论;他们应该给你一个很好的未来方向印象。

相关问题