WCF Message Logging

I use WCF to send some Linq objects via wire. I want to record the message size using message log or trace. However, I do not want, or am able to use, a configuration file to configure it. I'm struggling to figure out how to do this programmatically. I don't care if this happens on the client host. I control both.

Does anyone have any experience?

+3
source share
3 answers

Marc right, Message Inspectors will let you do this. Create a class that: implements IDispatchMessageInspector . The following is a method in which you can implement code to process a 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

In addition, the following Link may also help.

Luck

+3
source

Not programming, but maybe: wireshark ?

Also, review message controllers . However, I do not have a specific example of data logging.

0
source

Fiddler, HTTP-, wsHttp basicHttp. http://www.fiddler2.com/fiddler2/

0
source

Source: https://habr.com/ru/post/1708916/


All Articles