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;
}
}
}