473,586 Members | 2,870 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 5035
maybe check this article.

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

-Dino
"IanT" <it************ *****@hotmail.c om> wrote in message
news:1f******** *************** ***@posting.goo gle.com...
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.c om> wrote in message
news:1f******** *************** ***@posting.goo gle.com...
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
5820
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 brand new object when deserializing. In my case I have an existing object that I'd like to pass some XML to for the object to repopulate its member...
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 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...
2
9526
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> <Notes> some notes </Notes> </Report> <Report> blah blah blah </Report>
0
2163
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 and properties derived from this class but will not serialize or deserialize the properties in CollectionBase. Like InnerList, which is a read only...
1
7079
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 and properties derived from this class but will not serialize or deserialize the properties in CollectionBase. Like InnerList, which is a read only...
2
6058
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 BinaryFormatter stream. " } I looked at the serialized string vs whats passed into the deserialize
2
2420
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 MSDN example. The CODE is BELOW this lines. If you see something wrong or missing please answer. Class declaration:
17
1859
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
35631
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 the saved settings Can anyone see something that I have missed ?
0
7911
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7839
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8338
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7954
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8215
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6610
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5710
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3836
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3864
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.