Hi Stephen,
> We currently have an issue with serializing some objects into the body
> of a SoapEnvelope.
[quoted text clipped - 6 lines]
> ISerializable interface. So, nothing new there, just following good
> practice.
BUt all that doesn't have anything to do with this. Runtime serialization
(that is, that controlled by System.Runtime.Serialization) and Xml
serialization (as that used in asmx and WSE) are completely different
entities, and are controlled by entirely different sets of rules and
attributes.
> > Our issue is when we call SoapEnvelope.SetBodyObject(object), we
> receive a serialization error using the WSE soap formatter
[quoted text clipped - 11 lines]
> serialization.
> </rant warning>
Actually, I'd contend that the way the XmlSerializer works is far more
controllable (yes, it has more restrictions, but it allows you to control
the serialization format).
You might want to look into the IXmlSerializable interface instead of
ISerializable...

Signature
Tomas Restrepo
tomasr@mvps.org
Stephen Smith - 29 Jul 2004 09:39 GMT
Tomas
> > We currently have an issue with serializing some objects into the body
> > of a SoapEnvelope.
[quoted text clipped - 12 lines]
> entities, and are controlled by entirely different sets of rules and
> attributes.
I was originally setting the scenario. I should have ignored any
serialization statements here as they were only added later when
serialization using WSE failed. The point I was trying to get across
was that I was following a well-known pattern for distributed
applications, and hence I believe should be compatible with WSE.
However due to the 'hard-coded' serialization of the envelope body
object we found that it wasnt; unless we compromise our design or add
additional and in my view unnecessary client/service code.
> > > Our issue is when we call SoapEnvelope.SetBodyObject(object), we
> > receive a serialization error using the WSE soap formatter
[quoted text clipped - 15 lines]
> controllable (yes, it has more restrictions, but it allows you to control
> the serialization format).
Yes I am aware that runtime and XML serialization have differing basis
and provide differing functionality. What I contend is that the
approach is inconsistent. I would not argue with you over the
'additional' capabilities offered by the XmlSerializer, in fact I
don't care that one is better than the other. What I (currently) care
about is that I cannot pass an object that doesn't have an default
parameter-less constructor inside a SoapEnvelope.
From a naive viewpoint, I would suggest talking to the XmlSerializer
team about that 'opportunity' but as a more immediate response allow
the SoapEnvelope body object serializer to be pluggable. (I am
assuming from your reply it currently isn't)
> You might want to look into the IXmlSerializable interface instead of
> ISerializable...
I didn't consider the IXmlSerializable interface as it is declared for
internal use only! Secondly it doesn't overcome the parameter-less
constructor issue.
Sorry for sounding so negative on this subject, I do appreciated the
efforts of the WSE team. Just have found using it in a real life
scenario has proved that more soak testing is required! (see my
previous thread about Kerberos Multi-Hop delegation).
Steve
SA - 29 Jul 2004 23:00 GMT
Stephen:
I agree that sometimes it is cumbersome or 'unnatural' to have to have that
default ctor.
However, I also think that it would be a tough thing to create a
deserializer that can handle any type of ctor that happens to be used.
Especially, you'd run into issues with multiple ctors in your DTO classes.
As far as I am concerned, I provide read and write public properties and a
default constructor, and count my blessings that I don't have to start
writing XML serialization/deserialization myself...
Also, I am not first-hand familiar with Fowler's work, but I do use the DTO
model for my messages. I can hardly believe that Mr. Fowler would have
objected very much to having read and write DTOs.
My two cents...

Signature
Sven
> Tomas
>
[quoted text clipped - 70 lines]
>
> Steve
Stephen Smith - 30 Jul 2004 11:47 GMT
Sven
DTO's in my design are immutable and hence not really meant to be
read/write, the best way of achieving this (IMHO) is to pass in the
state during the object construction.
The parameterless constructor 'issue' has been overcome in the
'runtime' serialization versions by the coding practise of the special
constructor. Something similar could be implemented for the other
serialization mechanism's.
However, I would suggest that making the actual serializer pluggable
offsets the ownership from Microsoft/framework onto the application
developer. It is also a relative painless and can satisfy everyone's
needs.
For now I intend to take the hit on pre-serializing the object before
assigning it to the SoapEnvelope, as I prefer to keep the DTO's to the
original design.
Thanks for listening
Steve