我们可以在WCF消息检查器内注入服务吗?

发布于 2025-02-08 01:58:08 字数 711 浏览 1 评论 0原文

我有一个WCF应用程序,其中有消息检查器(IDISPATCHMESSAGEINSPECTOR)。现在,我想向其中注入服务,但无法弄清楚如何做到这一点或是否可能。

我有一个MVC项目在同一解决方案中,我可以在MVC操作过滤器中进行财产注入,但不确定如何使用WCF消息检查员进行。

这是我的消息检查员:

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

我尝试在AutoFac Bootstrapper中注册我的消息验证器,因此:

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

IfeAtureservice的注册已经完成并且在其他WCF服务中正常工作,但无法使其在消息检查员内部使用。 我该怎么做?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文