简体   繁体   中英

Castle Windsor XML configuration for WCF proxy using WCF Integration Facility

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM