473,383 Members | 1,759 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Recursive XML serialization? XML serialization of cyclic objects?

Hello. I have this kind of object:

class classA
{
int x;
classA z;

public int X
{
get { return this.x; }
set { this.x = value; }
}

public classA Z
{
get { return this.z; }
set { this.z = value; }
}

}

static class Program
{
static void Main(string[] args)
{
classA myObject = new classA();
myObject.X = 2;
myObject.Z = myObject;
}
}
How can I send "myObject" via XML webservice for consumption? I am aware
that this is not possible to be XML-serialized with .NET1.1 but, can I
do it with 2.0 or Indigo?

Thanks in advance,

Andrés [ knocte ]

--
Jan 11 '07 #1
2 9446
Hi Andrés,

No, it will not work in the 2.0 framework if the XmlSerializer detects a
circular reference.

You can have classA implement IXmlSerializable to handle the serialization.
Another option is to use WCF in the 3.0 framework to handle xml
serialization, which I read in an older article that it allows circular
references:

A. Skonnard, Serialization in Windows Communication Foundation
http://msdn.microsoft.com/msdnmag/is...n/default.aspx

§ Advanced Serialization Concepts
These new serializers can also maintain object references and deal with
issues like circular references (see the constructor with a
preserveObjectReferences flag). This is a nice improvement over
XmlSerializer, which choked on such object graphs. I can, for example,
serialize a circular spouse reference in the previous examples. I've
included such an example in the downloadable sample code.

I haven't tested this in WCF myself.

Windows Communication Foundation
Serialization and Deserialization
http://msdn2.microsoft.com/en-us/library/ms731073.aspx

--
Dave Sexton
http://davesexton.com/blog

""Andrés G. Aragoneses [ knocte ]"" <kn****@NO-SPAM-PLEASE-gmail.comwrote
in message news:um**************@TK2MSFTNGP02.phx.gbl...
Hello. I have this kind of object:

class classA
{
int x;
classA z;

public int X
{
get { return this.x; }
set { this.x = value; }
}

public classA Z
{
get { return this.z; }
set { this.z = value; }
}

}

static class Program
{
static void Main(string[] args)
{
classA myObject = new classA();
myObject.X = 2;
myObject.Z = myObject;
}
}
How can I send "myObject" via XML webservice for consumption? I am aware
that this is not possible to be XML-serialized with .NET1.1 but, can I do
it with 2.0 or Indigo?

Thanks in advance,

Andrés [ knocte ]

--

Jan 12 '07 #2
Dave Sexton escribió:
No, it will not work in the 2.0 framework if the XmlSerializer detects a
circular reference.

You can have classA implement IXmlSerializable to handle the serialization.
Another option is to use WCF in the 3.0 framework to handle xml
serialization, which I read in an older article that it allows circular
references:

A. Skonnard, Serialization in Windows Communication Foundation
http://msdn.microsoft.com/msdnmag/is...n/default.aspx

§ Advanced Serialization Concepts
These new serializers can also maintain object references and deal with
issues like circular references (see the constructor with a
preserveObjectReferences flag). This is a nice improvement over
XmlSerializer, which choked on such object graphs. I can, for example,
serialize a circular spouse reference in the previous examples. I've
included such an example in the downloadable sample code.

I haven't tested this in WCF myself.

Windows Communication Foundation
Serialization and Deserialization
http://msdn2.microsoft.com/en-us/library/ms731073.aspx
Thanks! I will take a look into it!

Regards,

Andrés [ knocte ]

--
Jan 16 '07 #3

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

Similar topics

0
by: James Sleeman | last post by:
Hi all, i just spent an hour rifling through code to find the cause of a problem only to find it's an oddity with serialization and recursive objects, so figured I'd post for the next person who...
7
by: Brian Sabolik | last post by:
I'm not sure if I've broken any Object Oriented rules or not, but ... I have projects in 2 different solutions that need to use each other's methods. Therefore I may have an "update" method in...
3
by: Vincenzino | last post by:
Hi, I have some problem in using SQL3 recursive queries on DB2 database system (8.1 and 8.2 UDB). I need to compute the transitive closure of a (possibly) ciclic graph using SQL3 on DB2. I MUST...
2
by: Maximus | last post by:
Hi Everyone, I was using Inprocess session objects, but incase of aspnet process crashes the session objects were lost as a result I decided to shift to out of porocess session objects. For this...
1
by: Joe Peterson | last post by:
I've been doing a lot of searching on the topic of one of Python's more disturbing issues (at least to me): the fact that if a __del__ finalizer is defined and a cyclic (circular) reference is...
2
by: skip | last post by:
We encountered a situation today where it appeared that a Boost.Python-provided class didn't participate in Python's cyclic garbage collection. The wrapped C++ instance held a reference to a...
0
by: Benjamin Kalytta | last post by:
Hello there, is there a way to override predefined Serializer for LINQ to SQL class objects? MSLinqToSQLGenerator generates classes for accessing Database. I want to create a Webservice...
3
by: from.future.import | last post by:
Hi, I encountered garbage collection behaviour that I didn't expect when using a recursive function inside another function: the definition of the inner function seems to contain a circular...
6
KevinADC
by: KevinADC | last post by:
This snippet of code provides several examples of programming techniques that can be applied to most programs. using hashes to create unique results static variable recursive function...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.