I pass an xmlDocument to my web service. There I want to use an xmlValidating
reader for validation of that document. I do not want to create a file, but
rather validate from a stream. My schema document specifies a boolean for an
element where, in the instance document, there is the value "2222".
The code:
(1)
Dim buf As Byte() = System.Text.UTF8Encoding.UTF8.GetBytes(oReport.Out erXml)
Dim ms As New MemoryStream(buf)
ms.Position = 0
tr = New XmlTextReader(ms)
--
I have also tried
(1a)
Dim myStream As System.IO.StringReader
myStream = New System.IO.StringReader(oReport.OuterXml.ToString)
tr = New XmlTextReader(myStream)
(1b)
Dim myStream As System.IO.StringReader
myStream = New System.IO.StringReader(oReport.OuterXml.ToString)
tr = New XmlTextReader(myStream)
tr.Read()
(1c)
tr = New XmlTextReader("C:\inetpub\wwwroot\mc\ws050523.1\fi le.xml")
(1d)
tr = New XmlTextReader("C:\inetpub\wwwroot\mc\ws050523.1\fi le.xml")
tr.Read()
--
(2)
vr = New XmlValidatingReader(tr)
AddHandler vr.ValidationEventHandler, AddressOf ValidationCallBack
Dim schema As String = "urn:myschema-schema"
Dim xsc As New XmlSchemaCollection
xsc.Add(schema, "C:\inetpub\wwwroot\mc\ws050523.1\myschema.xsd ")
vr.Schemas.Add(xsc)
While vr.Read()
End While
....
I can step through the proxy class created from the web service and using
vr.ReadString I see the values being read from either the file or from the
stream.
Using 2 with
(1) --> The expected validation exception is Not raised.
(1a) --> is Not raised.
(1b) --> is Not
(1c) --> is
(1d) --> is Not
Can anyone help me understand these results and why I can't use 1 & 2 to
validate the xmlDocument in the web service?
Thank you,
John Hopper