473,508 Members | 2,250 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Deserialize / Serialize / Validate

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
or previous posts would be greatly appreciated.
Nov 12 '05 #1
2 5025
maybe check this article.

http://msdn.microsoft.com/library/en...ce04162003.asp

-Dino
"IanT" <it*****************@hotmail.com> wrote in message
news:1f**************************@posting.google.c om...
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
or previous posts would be greatly appreciated.

Nov 12 '05 #2
maybe check this article.

http://msdn.microsoft.com/library/en...ce04162003.asp

-Dino
"IanT" <it*****************@hotmail.com> wrote in message
news:1f**************************@posting.google.c om...
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
or previous posts would be greatly appreciated.

Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
5808
by: Ian Tompsett | last post by:
H I was wondering if it possible for an object to serialize/deserialize itself from XML. I'd be guessing that it would need to use the XmlSerializer class, but that seems to want to create a...
0
378
by: IanT | last post by:
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...
2
9514
by: Greg | last post by:
I'm writing a class in C# .... I have a collection calls Reports made up of Report objects. I'm trying to deserialize an XML file that looks like : <Reports> <Report> <Title>some title</Title>...
0
2160
by: Mike Pollett | last post by:
Hi, I have used the ISerializable interface before and the code below worked fine. Until I derived it from CollectionBase. The code will still serialize and deserialize the properties in this class...
1
7070
by: Mike Pollett | last post by:
Hi, I have used the ISerializable interface before and the code below worked fine. Until I derived it from CollectionBase. The code will still serialize and deserialize the properties in this class...
2
6034
by: PCH | last post by:
I have 2 functions, one to serialize an object, and one to deserialize it. I can serialize just fine, the problem is when I try to deserialize it later... I get an error: {"Invalid...
2
2416
by: alexandre martins | last post by:
Every time i try to make Deserialize the computer gives me the folowing error: "End of Stream encountered before parsing was complete" the code that i'm running is simple and is based on an...
17
1850
by: Peter | last post by:
How would would you deserialize this example below? Imports System Imports System.Collections Imports System.IO Imports System.Xml.Serialization Public Class App1 Shared Sub Main()
2
35564
by: Joe | last post by:
Hi I have a Generics List in a PropertyGrid I am able to Serialize it to XML but when I try to deserialize back to the class of the PropertyGrid The Constructor doesn't seem to fire to reload...
0
7127
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
7054
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7501
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5633
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4713
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3188
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1564
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
768
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
424
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.