简体   繁体   中英

How to register all WCF service implementations in Castle Windsor

First of all sorry for maybe duplicated question but I'm new and at the same time excited about Castle Windsor project. I've refactored my Web API service to use advantages of DI and UnitTesting. Project structure : API(Web Api) > WcfServiceWrapper (Library Project) >> ( IAuthorizationService, IBussinesProcessService, IClientService ... (Service References)). All Service References have their configuration in config file.

In WcfServiceWrapper I was working with ex.:

using(IAuthorizationService serviceClient = new AuthorizationServiceClient()){
}

Now with Castle I want for all Referenced Services ( IAuthorizationService, IBussinesProcessService, IClientService ... ) use their implementations ( AuthorizationServiceClient, BussinesProcessServiceClient, ClientServiceClient ... )

Castle configuration is in API project. When I do this :

container.Register(Classes.FromAssemblyNamed("WcfServiceWrapper").Pick().WithServiceAllInterfaces());

at runtime it tells me that ComponentActivator: could not instantiate AuthorizationServiceClient .

I thought it cant read binding Configurations from config file or I don't know.

Can you tell me how can I register this components?

After more detailed search I found that it was common problem with bindings. I had to move all binding configuration from WcfServiceWrappers app.config to APIs web.config , so now all service clients can see their binding configuration which is needed in constructor.

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