开发者

How to prevent WCF message logging from eliding the SOAP body?

I have a WCF client for which I need to log messages. I need the complete SOAP envelope of both requests and replies.

My app.config file has logging set up thusly:

<diagnostics>
  <messageLogging logMalformedMessages="false" lo开发者_如何学PythongMessagesAtServiceLevel="true"
                  logMessagesAtTransportLevel="false" logEntireMessage="true" 
                  maxMessagesToLog="100" maxSizeOfMessageToLog="20000000" />
</diagnostics>

The message log is populated correctly... almost! For the requests only, the SOAP body is elided like this:

<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Id="signature_e">...</s:Body>

Does anyone have any idea now to get the full SOAP body into my log?


It turns out that one of the behaviors I had configured for this endpoint (an IClientMessageInspector) was creating a subclass of Message, and that this subclass didn't override OnBodyToString() which is used for logging. The default implementation of OnBodyToString() just prints out ... an ellipsis!

The Message class is a tricky beast indeed.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜