如何禁用我的状况的 MessageInspector
我使用 IDisptachMessageInspector 检查 WCF 服务,然后在 BeforeSendReply 方法中调用服务操作,该方法会更改消息的上下文。但是当我调用服务时,检查器再次运行。我不想运行检查员。你知道有什么方法可以做到这一点吗?
I inpesct WCF Service With IDisptachMessageInspector and then I call service operation at BeforeSendReply Method which changes context of message. But it when I call service , Inspector runs again. I want to not run inspector. Do you know any way to do that scenerio?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
消息检查器的目的是允许您在服务模型层的其余部分处理消息之前或之后修改消息。BeforeSendReply
在调用操作之后调用,AfterReceiveRequest 在调用操作之前调用。
您看到的行为是您的消息检查器在操作后被触发。然后,您将触发另一个操作,最终再次调用您的消息检查器。 BeforeSendReply 通常用于将响应消息操纵为 WCF 使用其默认序列化等生成时存在问题的某种格式。它无法为您提供您正在寻找的行为
要决定调用哪个操作,您通常会实现IDispatchOperationSelector。这个扩展点的具体想法看起来正是你所需要的
The purpose of a message inspector is to allow you to modify the message before or after the rest of the service model layer processes it
BeforeSendReply is called after the operation has been invoked already, AfterReceiveRequest is called before the operation is invoked.
The behavior you are seeing is that your message inspector is being fired after the operation. You are then firing another operation which then ends up calling your message inspector again. BeforeSendReply is often used to manipulate the response message to some format that WCF has problems with generating using its default serialization, etc. Its not going to be able to give you the behavior you are looking for
To decide on which operation is invoked you normally implement an IDispatchOperationSelector. The specific idea of this extension point looks like it will be exactly what you need
答案是实现 IOperationInvoker
Answer is implementing IOperationInvoker