开发者

What is the lowest interception point in the WCF runtime stack?

开发者 https://www.devze.com 2022-12-17 11:35 出处:网络
I wish to debug why my applica开发者_如何学Pythontion sends so much data using WCF underneath. I tried to examine WCF trace logs and examine the traffic with Fiddler, but I need a stack trace leading

I wish to debug why my applica开发者_如何学Pythontion sends so much data using WCF underneath. I tried to examine WCF trace logs and examine the traffic with Fiddler, but I need a stack trace leading to the offending client code.

So, I installed a custom IClientMessageInspector, but how can I know the size of the actual data given a Message instance? The ToString() of the given Message instance returns an XML, but I am not sure if its size is it.

Is there a way to hook into the WCF stack even deeper and closer to the actual sending of the message?

UPDATE

Found this SO question 1 year old, funny, but no one answered it - https://stackoverflow.com/questions/457683/message-size-after-serialize


You mention the trace logs - but have you enabled message logging? With this in place, you should have clear visibility of the underlying messages, so you should be able to see exactly what data is on the wire?


You can use the message interceptor, however note that "the body of a message can only be consumed ... once" (see msdn).

In essence you need to use Message.CreateBufferedCopy() to create a copy of the message to deal with as you like, including calling ToString() to dump it somewhere.

Also, when message interceptors are chained, you might not see the original message, but rather the one that the previous interceptor has created / altered.

So, if you really just want to see what is on the wire, you're probably better off with the builtin WCF tracing, as Marc already said.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号