记录WCF消息大小 [英] Logging WCF message sizes

查看:51
本文介绍了记录WCF消息大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用WCF通过导线发送一些Linq对象.我想使用消息记录或跟踪来记录消息大小.但是我不想要,也没有能力使用配置文件进行设置.我正在努力找出如何以编程方式执行此操作.我不在乎这是否发生在客户的主机上.我两个都控制.

I am using WCF to send some Linq objects across the wire. I want to log message size either using Message logging or tracing. I don't however want, or have the ability to use the config file to set this up. I am struggling to figure out how to do this programatically. I don't care if this happens at the host of client. I control both.

有人有这样做的经验吗?

Does anyone have experience doing this?

推荐答案

马克的权利,消息检查器将允许您执行此操作.创建一个类,该类:实现 IDispatchMessageInspector .下面的方法将可用,您可以在其中实现用于操纵请求消息的代码.

Marc's right, Message Inspectors will allow you to do this. Create a class that: Implements IDispatchMessageInspector. The below method will be made available where you can implement code to manipulate the request message.

Public Function AfterReceiveRequest(ByRef request As System.ServiceModel.Channels.Message, ByVal channel As System.ServiceModel.IClientChannel, ByVal instanceContext As System.ServiceModel.InstanceContext) As Object Implements System.ServiceModel.Dispatcher.IDispatchMessageInspector.AfterReceiveRequest
    'Output the request message to immediate window
    System.Diagnostics.Debug.WriteLine("*** SERVER - RECEIVED REQUEST ***")
    System.Diagnostics.Debug.WriteLine(request.ToString())

    Return Nothing
End Function

此外,以下链接也可能会提供一些帮助.

Also, the following Link may also provide some help.

祝你好运

这篇关于记录WCF消息大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆