problem validating xml against schema

  • Thread starter Thread starter Mike P
  • Start date Start date
M

Mike P

I have a web app that has been running happily for months, and on
Saturday it suddenly decided that it no longer wanted to validate my
XML. Here is my code and sample schema, and example XML :

public void ValidateAgainstSchema(object sender, ValidationEventArgs
args)
{
blnInvalidXML = true;
}

//in page load :

XmlTextReader tr = new XmlTextReader(new
StringReader(strReceivedXmlDoc));
XmlValidatingReader trv = new XmlValidatingReader(tr);

trv.ValidationType = ValidationType.Schema;

trv.ValidationEventHandler +=
new ValidationEventHandler(this.ValidateAgainstSchema);

while (trv.Read())
{
}

if (blnInvalidXML == false)
{
//do stuff
}

Schema :

<?xml version="1.0" encoding="iso-8859-1" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="rsp-vcn">
<xs:complexType>
<xs:sequence>
<xs:element name="auth">
<xs:complexType>
<xs:sequence>
<xs:element name="cug" type="xs:long" />
<xs:element name="pasw" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="service">
<xs:complexType>
<xs:sequence>
<xs:element name="countrycode" type="xs:string" minOccurs="1" />
<xs:element name="number" type="xs:string" minOccurs="1" />
</xs:sequence>
<xs:attribute name="type" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="query" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="message_id" type="xs:byte" use="required" />
</xs:complexType>
</xs:element>
</xs:schema>

XML :

<?xml version="1.0" encoding="iso-8859-1" ?>
<rsp-vcn message_id="0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://www.calluk.com/vcn/query.xsd">
<auth>
<cug>5790</cug>
<pasw>****</pasw>
</auth>
<service type="query">
<countrycode>1</countrycode>
<number>7813941801</number>
</service>
</rsp-vcn>

I can navigate to the schema in IE, and when I send through XML that the
schema should validate, it doesn't. I am stumped as this code has
worked fine for months.


Can anybody please shed any light on this?


Cheers,

Mike
 
Back
Top