Groups | Blog | Home
all groups > dotnet xml > june 2004 >

dotnet xml : Deserialize / Serialize / Validate


itinsleyTAKETHISOUT NO[at]SPAM hotmail.com
6/14/2004 7:34:25 PM
Hi

I need help with my approach to validating de-serialized XML received
via webservice. Hopefully someone can point me to sources detailing
best practice for the following.

I agreed a standard data format with my client using an XSD. During
development we transferred actual XML files which i validated against
the XSD, this was no problem.

To allow uploading of the same data via a webservice, i used xsd.exe
to create classes reflecting the XSD and created a webservice method
that accepts a parameter of the root element of the XSD.

Now i am trying to validate the received object (deserialized xml)
using an xml validator but can only do it by serializing the object to
XML, actually saving it to a file and validating it. I've tried
validating it using the memoryStream created by serializing the
classes but have no success.

Question 1. Can i serialize to a memoryStream and validate that
stream.
Question 2. The whole process seems convoluted - am i missing the
point?
i.e.
Webservice does the following:
* Receives Class containing Data
* Serializes to XML, validates against XSD
* Create DataSet from XML (i.e. deserializes again)
* Loads data from dataset into SQL database

I accept i could load the data directly into SQL from the object
received from the Webservice but at what point would i validate that
the object conforms to the XSD.

I appreciate this is a very broad question - any pointers to articles
Dino Chiesa [Microsoft]
6/15/2004 8:31:02 PM
maybe check this article.

http://msdn.microsoft.com/library/en-us/dnservice/html/service04162003.asp

-Dino


[quoted text, click to view]

AddThis Social Bookmark Button