[Mono-list] Recursive XML serialization? XML serialization of cyclic objects?
Robert Jordan
robertj at gmx.net
Fri Jan 12 08:51:28 EST 2007
Hi Andrés,
Andrés G. Aragoneses [ knocte ] wrote:
>> I'm not aware of any Web Service standard allowing that
>> kind of cycles.
>
> Neither if I create my custom XmlSerializer? How can I tell my ASP.NET
> webservice to use it instead of the default one?
.NET 1.1 does not support custom XML serializers, i.e.
by providing a new XmlSerializer implementation, but
the XML serialization can be controlled up to some level.
(I guess you already know this).
>> If you really need such complex classes and you don't
>
> Well, it's not that complex to have a domain model that allows it. For
> example, a very common scenario:
I meant "complex for XML serialization", which in many cases means
"basic" for domain models.
>> Anyway, my strong opinion is: *never* employ remoting or Web Services
>> w/out a remoting facade pattern that maps between complex objects
>> and simple (remotable) objects.
>
> Well, I think I understand your concern about this. However I think we
> were using this pattern until we realised we had to write many code for
> each class of the domain model so as to write these translation
> mechanisms. Then we opted for a totally transparent solution that,
> however, needs a reflection-based conversion so as to mark some parts of
> the objects as "lazy" (not retrieved) and be able to serialize them.
>
> In case you are interested, I wrote a blog post about it (it's based on
> NHibernate mapping framework; oh! and sorry, it's written in Spanish but
> perhaps you can more or less understand it using the automatic
> translation service link I have at the top of the page).
You could annotate the domain model with some custom attributes
and create proper XML-serializable proxy classes from them.
It's also the place where you probably could handle Hybernate's
lazy collections.
What I don't understand: why do you need Web Services? It seems
to be a .NET-only project where you could use Remoting instead,
which is less constrained: binary serialization can be customized
much better than XML; MarshalByRefObjects can be used to pull
data on demand from lazy collections, etc.
Robert
More information about the Mono-list
mailing list