WCF using Enterprise Library Health Checker Application Block - how to get invalid messages?

I have some WCF services (hosted in IIS 6) that use a health check application block (4.0). If a client sends a message that does not validate (i.e. returns in an exception ValidationFault

), I would really like to be able to write the XML message somewhere (using code, IIS logs). All validation is done before the service implementation code is started.

I'm sure it is possible to configure some class to run before the service is implemented (apparently this works with the Application Validation block), but I can't remember how, or determine exactly what to look for.

Is it possible to create a class and associated configuration that will give me access to the entire SOAP request message, or at least the body of the message?

+2


source to share


3 answers


I found a blog post that seems to do what I want - you create a class that implements IDispatchMessageInspector

. In the method AfterReceiveRequest

, you have access to the entire incoming message, so you can log out. This happens after authentication, so you also have access to the username - convenient for logging. You can create helper classes that allow you to assign this behavior to services through attributes and / or configuration.

IDispatchMessageInspector

also provides a method BeforeSendReply

so you can log (or modify) your reply message.



Now that clients try to literally pass SOAP request requests (without even using any DOM object) to our services, we have easy-to-access proof that they are sending garbage!

0


source


Take a look at using App Block to enforce policy ...

I am currently developing an application where I intercept (using PIAB) all requests coming to the server and depending on the type of request I apply a different validation behavior with VAB.

Here's an article on integrating PIAB with WCF:



http://msdn.microsoft.com/en-us/magazine/cc136759.aspx

You can create various mechanisms of intuition, such as attributes, to be applied to open transactions.

+1


source


You can log the whole WCF message:

http://msdn.microsoft.com/en-us/library/ms730064.aspx

Or, you can combine it with the Enterprise Library Logging Application Block.

0


source







All Articles