I am trying to implement multitenancy in a WCF application but facing some issues.
So I already have Autofac configured in the app and Autofac also supports multitenancy with WCF
Now my scenario is little different. I have a mobile app that's consuming this WCF service. And the service is deployed on Azure and we've front door configured so I can use X-Forwarded-Host header to extract the tenant information so that's not a problem.
Now the main issue is I have a TenantService that I need to setup for each request and then I can use the same TenantService wherever I want within the request scope.
I also implemented multitenancy in one of the MVC app and WebApi. But there we've an option to implement OwinMiddleware where we can setup the TenantService and that remains tenant aware within the request scope.
In Wcf I tried adding a MessageInspector and IServiceBehavior but the Bahavior created only once and it acts like a singleton so if I inject TenantService in my Behavior and pass that to the MessageInspector then it always have the same copy of the TenantService which I don't want.
I want to use something similar to the owin middleware but in WCF. What are the best options?