Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
基于对传入请求的处理,我必须将原始(未序列化)消息作为字符串存储到数据库中。
到目前为止,我实现了用于装饰服务实现的 aDispatchMessageInspector和 a 。ServiceBehavior我DispatchMessageInspector有一个存储消息字符串的属性。我的服务实现包括一些检查请求的业务规则,如果检查失败,我想存储原始消息。
DispatchMessageInspector
ServiceBehavior
如何DispatchMessageInspector以优雅的方式从服务实现中访问我的消息字符串属性?
您可以以您喜欢的形式添加包含原始消息的消息属性。然后在您的服务中,您可以通过OperationContext.Current.IncomingMessageProperties["RawMessage"].
OperationContext.Current.IncomingMessageProperties["RawMessage"]