views:

63

answers:

1

Does anyone know how to configure WCF using Windsor on IIS 7.0? I'm using the latest from WCF Windsor facility trunk and Windsor 2.1.1. The example on http://www.castleproject.org/container/facilities/trunk/wcf/index.html is out of date. Even demo project in WCF facility doesn't mention how to setup WCF service in IIS using the config and I couldn't find any example where I can setup WCF on server side using system.serviceModel section of web.config or even through code. When I use the following code it always creates basicHttpBinding and I couldn't figure out how to setup different bindings.

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
            );
}

And here is MyService.svc

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

I recently wrote a blog post about Windsor's WCF Facility. Be sure to read the comments as well, as they include a discussion involving one of Windsor's active committers; they should give you a pretty good impression of the future direction.

Mark Seemann
Thanks for the answer Mark. Your article and comments talk about where to setup Service host factory which is great. My question is about how to get configuration setup with different bindings than default one. There's nothing mentioned there about that, neither is in comments. I should mention as well that I'm new to Windsor.I also don't know how to hookup that service host factory to install when IIS application is started.
Ali Bolourian
Windsor has nothing to do with controlling the bindings. You should do that through the standard WCF configuration elements: http://msdn.microsoft.com/en-us/library/ms731320(v=VS.100).aspx
Mark Seemann
As I mentioned in the question, it doesn't pick up bindings from WCF configuration file. It only binds basicHttpBinding even though I have wsHttpBinding specified in web.config. Interestingly if I comment out the whole WCF config from web.config, service is still initialized the same way with basicHttpBinding. I suspect I'm missing something and that's why I'm looking for a sample.
Ali Bolourian
Mark, here's the new changes I made to the code based on your blog posting. However I'm getting the following error:"Could not find a component with name MyService, did you forget to register it?"Now when I add the component like below (Added Named()), MyService.svc tells me that "Metadata publishing for this service is currently disabled." which is not the case because I added mex endpoint to config. Any ideas?container.Register( Component .For<MyService>() .Named("Myervice") .LifeStyle.Transient);
Ali Bolourian