WCF Integration and WebServiceHostFactory

Apr 11, 2014 at 11:36 AM

Any chance of the WCF integration getting support for WebServiceHost and WebServiceHostFactory in the future?

On first sight it looks like the implementation would be identical to SimpleInjectorServiceHost(Factory) but with a different base class. Because classes like SimpleInjectorServiceBehaviour are internal I can't really build on top of the integration support in my own project. I could duplicate source code from the integration package, but I'd rather not :)
Apr 11, 2014 at 11:49 AM
Are you referring to Windows Process Activation Services (WAS)? We are actually planning to making both the SimpleInjectorServiceBehavior (issue) and the SimpleInjectorServiceHostFactory for the next minor release.

Does this answer your question?
Apr 11, 2014 at 12:01 PM
I use ServiceRoute from using System.ServiceModel.Activation.

RouteTable.Routes.Add(new ServiceRoute("Service", new SimpleInjectorServiceHostFactory(), typeof(MyService)));

this hosts the service under the /Service route

With a ServiceHost that inherits from System.ServiceModel.Web.WebServiceHost I can host the same service as a web service that returns json or plain old xml.

RouteTable.Routes.Add(new ServiceRoute("JsonService", new SimpleInjectorWebServiceHostFactory(), typeof(MyService)));
Apr 11, 2014 at 12:26 PM
I just checked the SimpleInjector source code again and I think that with SimpleInjectorServiceBehavior public this would be trivial to implement for me. I just have to reference System.ServiceModel.Web and implement two classes almost identical to SimpleInjectorServiceHost and Factory.

You could consider adding this to the integration package if you don't mind the dependency on System.ServiceModel.Web.

I need to do this to keep a legacy service up in the air beside the new one I'm building now. The current legacy application uses Autofac which has a factory for ServiceHost and one for WebServiceHost.

May 6, 2014 at 10:13 PM
Would really appreciate if you could support WebServiceHost. Right now, I am duplicating your integration package to support that.
May 7, 2014 at 4:58 AM
We plan to support this in the next minor release.
Aug 31, 2014 at 9:28 PM
We just pushed the Simple Injector 2.6 beta1 to NuGet and the SimpleInjectorServiceBehavior is now part of the public API of the WCF integration package. If you like you can check it out to see whether this solves the problems you're having.
Oct 21, 2014 at 5:51 PM
Simple Injector 2.6 was released last week. No further changes were made since the beta1 release of the WCF integration package.
Oct 22, 2014 at 5:23 AM
This works for me. Thanks a lot Steven.