views:

305

answers:

2

Hi everybody!

Currently, we use programming registration of WCF proxies in Windsor container using WCF Integration Facility. For example:

container.Register(
    Component.For<CalculatorSoap>()
      .Named("calculatorSoap")
      .LifeStyle.Transient
      .ActAs(new DefaultClientModel
      {
        Endpoint = WcfEndpoint.FromConfiguration("CalculatorSoap").LogMessages()
      }
      )
      );

Is there any way to do the same via Windsor XML configuration file. I can't find any sample of this on google.

Thanks in advance

A: 

Using IWindsorInstaller and doing the registration through code is the recommended way. Config is for configuration (and legacy scenarios).

I'd create two installers for this and based on compilation flag use one or the other;

var installer = 
#if DEBUG
new TestingServiceInstaller();
#elseif
new ProductionServiceInstaller();
#endif

container.Install(installer);
Krzysztof Koźmic
+1  A: 

Castle WCF Integration Facility repository (http://github.com/castleproject/Castle.Facilities.Wcf) now contains sample of WCF client registration from Windsor configuration file:

<?xml version='1.0' encoding='utf-8' ?>
<configuration>
<facilities>
    <facility id='wcf' 
              type='Castle.Facilities.WcfIntegration.WcfFacility,
                    Castle.Facilities.WcfIntegration' />
</facilities>

<components>
    <component id='calculatorSoap'
               type='Demo.CalculatorSoap, Demo.UnitTests'
               wcfEndpointConfiguration='CalculatorSoap'>
    </component>
</components>
</configuration>

That is what I was looking for. Thank you for your help.

Note: pay attention on lifestyle. In common case, WCF proxy must have transient lifestyle to be closed on object release. While default Windsor lifestyle is singleton, in this case WCF proxy will be closed on container disposal.

Regards, Andrej

Andrej Golcov