How do I use StructureMap in a WCF 4.0 REST service?
I've used StructureMap in the past using this article but the technique doesn't seem to work with the WebServiceHostFactory()
. What's the secret?
How do I use StructureMap in a WCF 4.0 REST service?
I've used StructureMap in the past using this article but the technique doesn't seem to work with the WebServiceHostFactory()
. What's the secret?
I got it to work following this example. Essentially you write a customer BehaviorExtension
instead of a ServiceHostFactory
and life is good.
Would still appreciate any understanding as to why using a custom WebServiceHostFactory
doesn't work. It appeared to wire everything up correctly but my IInstanceProvider
's GetInstance()
method was never being called.
The method in the previous example article can be made to work by:
StructureMapServiceHost
from WebServiceHost
and not ServiceHost
StructureMapServiceHostFactory
from WebServiceHostFactory
and not ServiceHostFactory
The benefit of this? No web.config changes required. It's all done programatically.