If you need to validate parameters, use parameter inspectors

J.D. Meier, Jason Taylor, Prashant Bansode, Carlos Farre, Madhu Sundararajan, Steve Gregersen.

If you need to validate operations that do not accept message or data contracts, use parameter inspectors. Parameter inspectors provide a convenient mechanism to process service method invocations when they are in a parameterized form. It allows pre and post processing of messages through the use of custom validators. Unlike using a schema for validation, a custom validator requires you write your own custom validation code.

To implement Parameter inspectors, write a class that implements IParameterInspector, which defines two methods, AfterCall and BeforeCall. The AfterCall method is called just before the response message is sent from the service operation back to the client and the BeforeCall method is called just before the message is dispatched to the service operation.
The AfterCall method of an IParameterInspector correspond to the AfterDeserialize message state i.e., the request after going through the XML serializer and the BeforeCall method of an IParameterInspector correspond to the BeforeSerialize message state i.e., the response before going through the XML serializer.
Example
public class Validation
{
       public class ValidationParameterInspector : IParameterInspector
        {
            public void AfterCall(string operationName, object[] outputs, object returnValue, object correlationState)
            { … 	}


		public object BeforeCall(string operationName, object[] inputs)
            { …    }
	…
}

Last edited Apr 16, 2008 at 11:45 PM by prashantbansode, version 1

Comments

Sacode Apr 27, 2008 at 6:46 AM 
"The AfterCall method of an IParameterInspector correspond to the AfterDeserialize message state i.e., the request after going through the XML serializer and the BeforeCall method of an IParameterInspector correspond to the BeforeSerialize message state i.e., the response before going through the XML serializer."

May be:
BeforeCall method correspond to the AfterDeserialize. AfterCall method orrespond to the BeforeSerialize.
?