How can I correctly register messages sent and received from a WCF client

Please do not reply using the WCF Trace Tool unless you give clear instructions on how to capture the actual message, including headers and errors. The link does not work.

Also, do not respond to the IClientMessageInspector unless you know how to make it include all the headers (which is not the case) and capture responses with error elements that are not parsed.

With pre-wcf web services, you can write a SoapExtension that worked flawlessly.

+7
source share
3 answers

write a custom message encoder . he has access to all the headers. depending on how versatile you want your solution to be, you may need to write it so that it falls into the ctor of the real encoder.

just a few days ago I implemented "Encoder Wrapper" in this thread . this encoder changed the message. you don’t need to do this, you can just register it and transfer it to transport, just like me.

+3
source

A class that implements IEndpointBehavior allows you to capture and register incoming / outgoing messages.

See an example here http://msdn.microsoft.com/en-us/library/system.servicemodel.description.iendpointbehavior.applydispatchbehavior.aspx

You will also need a class that implements IDispatchMessageInspector

+2
source

I found this one :

 <system.diagnostics> <sources> <source name="System.ServiceModel.MessageLogging"> <listeners> <add name="messages" type="System.Diagnostics.XmlWriterTraceListener" initializeData="c:\log\wcfMessages.svclog" /> </listeners> </source> </sources> </system.diagnostics> <system.serviceModel> <diagnostics> <messageLogging logEntireMessage="true" logMalformedMessages="true" logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" maxMessagesToLog="1000000" maxSizeOfMessageToLog="10000000"/> </diagnostics> </system.serviceModel> 

This is not ideal, since you need to use a tool to view messages, but it seems to capture the actual messages with all headers and errors, etc.

+1
source

All Articles