Archive

Posts Tagged ‘Facilities’

Castle Windsor WCF Facility

March 5, 2010 Leave a comment

Firstly download this from the trunk, git://github.com/castleproject/Castle.Facilities.Wcf.git and build the sources. Once you have this installed then you need to get Castle Windsor to configure the facility as shown below

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

            container.Register(
                    AllTypes.FromAssembly(Assembly.GetExecutingAssembly())
                            .Where(x => x.Name.Contains("Repository"))
                            .WithService
                            .FirstInterface()
                            .Configure(x => x.LifeStyle.Transient)
                );

            container.Register(
                    AllTypes.FromAssembly(Assembly.GetExecutingAssembly())
                            .Where(x => x.Name.Contains("Service"))
                            .WithService
                            .FirstInterface()
                            .Configure(x => x.LifeStyle.Transient)
                );

If your using WAS or IIS to host your services add the following line to the ServiceHost definition in the .svc file.

<%@ ServiceHost Language="C#" Debug="true" Service="Test.WebServices.Services.ProjectService" Factory="Castle.Facilities.WcfIntegration.DefaultServiceHostFactory, Castle.Facilities.WcfIntegration" CodeBehind="ProjectService.svc.cs" %>

Now your ready to rock and roll. You configure the rest of WCF as you would as per normal.

Blair…