We are using the routing functionality to give our RESTful WCF service nice endpoints, however I ran into trouble, none of our services were being injected.
The service had two constructors which seemed odd, an empty one and one with dependencies specified…
public Api(IBasket basketService)
_basketService = basketService;
The injected services were NULL, so I removed the public constructor and got:
This sounds like the default WCF factory at work, checking the SVC files we get:
That’s also configured correctly, but we have overridden the default routing, let’s take a look at that:
RouteTable.Routes.Add(new ServiceRoute("Api", new ServiceHostFactory(), typeof(Api)));
That looks like the default WCF factory to me… Doh! Let’s fix that up…
RouteTable.Routes.Add(new ServiceRoute("Api", new DefaultServiceHostFactory(container.Kernel), typeof(IApi)));
Great, we are now using the windsor factory, and we can remove the default parameter-less constructor from our API service.