Home > Development > Castle Windsor WCF Facility

Castle Windsor WCF Facility


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…

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: