How to validate inbound messages on a service

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

Implement the AfterReceiveRequest of the interface IDispatchMessageInspector of a message inspector to validate inbound messages on a service. This allows you to validate the message after the request has arrived but before service operation invocation and deserialization.
object IDispatchMessageInspector.AfterReceiveRequest(ref System.ServiceModel.Channels.Message request, System.ServiceModel.IClientChannel channel, System.ServiceModel.InstanceContext instanceContext)
{
    try
    {
        validateMessage(ref request);
    }      
    catch (FaultException e)
    {
        throw new FaultException<string>(e.Message);
    }
    return null;
   
}

Last edited May 8, 2008 at 7:26 AM by prashantbansode, version 1

Comments

No comments yet.