/// <summary>
        /// Inspect the response message and do the schema validation.
        /// </summary>
        /// <param name="reply">The message to be transformed into types and handed back to the client application.</param>
        /// <param name="correlationState">Correlation state data</param>
        public void AfterReceiveReply(ref System.ServiceModel.Channels.Message reply, object correlationState)
        {
            this.lastRawResponseMessage = reply.ToString();

            if (this.ValidationEvent != null)
            {
                CustomerEventArgs args = new CustomerEventArgs { RawRequestXml = this.lastRawRequestMessgae, RawResponseXml = this.lastRawResponseMessage };
                this.ValidationEvent(this, args);
            }
        }
        /// <summary>
        /// Validate the response xml.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">An CustomerEventArgs that contains event data.</param>
        public void ValidateSchema(object sender, CustomerEventArgs e)
        {
            if (!string.IsNullOrEmpty(e.RawRequestXml))
            {
                this.site.Log.Add(LogEntryKind.Debug, "The raw xml request message is:\r\n{0}", e.RawRequestXml);
                XmlDocument requestXml = new XmlDocument();
                requestXml.LoadXml(e.RawRequestXml);
                SchemaValidation.LastRawRequestXml = requestXml.DocumentElement;
            }
            else
            {
                SchemaValidation.LastRawRequestXml = null;
            }

            if (!string.IsNullOrEmpty(e.RawResponseXml))
            {
                this.site.Log.Add(LogEntryKind.Debug, "The raw xml response message is:\r\n{0}", e.RawResponseXml);

                MemoryStream ms = new MemoryStream(System.Text.ASCIIEncoding.ASCII.GetBytes(e.RawResponseXml));
                XmlReader xmlReader = XmlReader.Create(ms);
                e.ValidationXmlReaderOut = xmlReader;

                XmlDocument responseDoc = new XmlDocument();
                responseDoc.LoadXml(e.RawResponseXml);
                SchemaValidation.LastRawResponseXml = responseDoc.DocumentElement;

                if (this.performSchemaValidation)
                {
                    SchemaValidation.ValidateXml(this.site, this.ignoreSoapFaultSchemaValidationForSoap12);

                    if (this.throwException 
                        && ((ValidationResult.Error == SchemaValidation.ValidationResult)
                           || (ValidationResult.Warning == SchemaValidation.ValidationResult)))
                    {
                        throw new XmlSchemaValidationException(SchemaValidation.GenerateValidationResult());
                    }
                }
            }
            else
            {
                SchemaValidation.LastRawResponseXml = null;
            }
        }