I'm trying to see if this is possible. I want to resolve the WCF service class from castle windsor via a factory class. The WCF service is hosted in IIS and so far I've only been getting a 404 when I try to call the service when using the factory. Here is my registration code:
container.AddFacility<WcfFacility>();
container.Register(Component.For<IServiceFactory>()
.ImplementedBy<ServiceFactory>()
.LifestyleSingleton());
container.Register(Component.For<IFooService>()
.UsingFactoryMethod((kernel, context)
=> kernel.Resolve<IServiceFactory>()
.CreateService(context.RequestedType))
.Named("FooService")
.LifestylePerWcfOperation());
Here is my factory class:
public class ServiceFactory : IServiceFactory
{
public IFooService CreateService(Type forType)
{
IFooService createdType = null;
if (forType == typeof(IFooService))
createdType = new FooService();
return createdType;
}
}
I have tried doing a strait .ImplementedBy<FooService>() and that works fine. It's only when I want to do it via a factory that I have a problem. Is this possible, meaning I'm missing something, or is it not possible?
(I know that the code shown is pretty simple, I am only testing if its possible before fully implementing my factory code)