Serializing Object Model

  • Thread starter Thread starter Dave T
  • Start date Start date
D

Dave T

From a web service I'm serializing out an object model. Is there a way to
only include those elements of the object model which actually contain data?
 
Dave T said:
From a web service I'm serializing out an object model. Is there a way to
only include those elements of the object model which actually contain
data?

It can be done, you will need a to write custom serializer for for that.
I've written one before and don't remember it being too difficult.

If you do that, though, you may have trouble deserializaing the result to
any wsdl-generated classes you may be using on the consumer side. To get
around that you could break down the object in question into a hierarchy of
classes; in that case you could probably eliminate your need for a custom
serializer to crop away empty fields altogether if you're dealing with a
broad yet deep tree of data.

All that being said: if your reason for doing this is size, I wouldn't
bother; 99% of the time doing this would be poor design, and if you turn on
(or manually implement) compression you'll find that XML data shrinks by a
factor of 30 because of its high tokenization.

Paul
 
Back
Top