Can we inject a service inside of a wcf message inspector?

74 Views Asked by At

I have a wcf application where I've a message inspector (IDispatchMessageInspector). Now I want to inject a service into it but can't figure out how to do that or if it's possible or not.

I've a mvc project in the same solution and I can do property injection in mvc action filters but not sure how to do same with wcf message inspectors.

Here is my message inspector:

    public class MessageValidator : IDispatchMessageInspector
    {
        public IFeatureService FeatureService { get; set; }
        public object AfterReceiveRequest(ref Message request, IClientChannel channel, InstanceContext instanceContext)
        {
          ///
        }
   }

And I've tried registering my message validator in the autofac bootstrapper like this:

builder.RegisterType<MessagaeValidator>().SingleInstance().PropertiesAutowired();

The registration for IFeatureService is already done and working fine in other wcf services but can't make it work inside of a message inspector. How can I do this?

0

There are 0 best solutions below