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 ]
--
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/issues/06/08/ServiceStation/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 ]"" <kno...@NO-SPAM-PLEASE-gmail.com> wrote
in message news:umZeBSaN...@TK2MSFTNGP02.phx.gbl...
Thanks! I will take a look into it!
Regards,
Andrés [ knocte ]
--