I am using WCF to implement a web service. This web service requires a 'ping' feature in the form of a health monitor for each service. This functionality is implemented using the IDispatchMessageInspector and is configured for each endpoint of a service. This is due to the need to have as close to the actual service code as possible for 'Ping'. Also, I did not want to pair it in the code of each service implementation and the IDIPF Message Inspector looks a good fit.
This service uses the request-answer MEP. Each request message contains an element that specifies which resource is needed. Then the message will use to determine how this message will process the data. The use of the same element is used to define a 'message' as the 'heartbeat' probe.
The 'Ping' message inspector will later post the request message in the process of the next, and if it determines that the request is a 'heart beat', it will then produce the correct reaction and the first syndrip ( ) The method is obtained through a correlation object since the latter is afterReceiveRequest (). According to the reference, AfterReceiveRequest () is set to clear the message parameter, then to stop the message from being processed by the service implementation code.
The technique to set the request message was found to be zero in a web site or blog which I can not remember nor find the URL. This technique works very well on itself and I can stop the service implementation code if it is requested to 'heartbeat'.
Unfortunately, to send empty messages in the Message Inspector to the WCF Runtime always throw a NullReferenceException stack trace, I still have to run the Runtime message object (which go through the 'Ping' message inspector Will be empty after) send to the sender and when the sender wants to delete an empty message object, NullReferenceException happens.
However, my system also applies IErrorHandler to capture and log any unrestricted exception in the service. This means that requests for every successful 'heartbeat' will generate the log entry for the tone reference option and 'heartbeats' can occur as often as each minute.
Question:
What can I do to stop the entry of 'useless' when the 'empty space' was dropped, the extension was thrown when 'Ping' service execution code canceled Prevents the request from being set.
Many thanks in advance.
hg
Not the most attractive solution but the potential solution (which I have not tested ), But where do you find your ping call in the inspector code, can not you throw your own custom exception type i.e. PingRequest Expression, and when it returns to the client, can handle it? Do you avoid killing the WCF runtime code, thus avoiding logging of obsolete exceptions.
Otherwise, you can try to use the base service inherited by all of your services (on the other side of the WCF Runtime Code), which ping requests in the manufacturer before hitting the actual service code And handles. / P>