Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net Web Services (http://www.velocityreviews.com/forums/f64-asp-net-web-services.html)
-   -   Serializing Object Model (http://www.velocityreviews.com/forums/t787501-serializing-object-model.html)

Dave T 03-24-2008 04:07 PM

Serializing Object Model
 
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?

PJ6 03-24-2008 04:45 PM

Re: Serializing Object Model
 
"Dave T" <DaveT@discussions.microsoft.com> wrote in message
news:F3016B1A-4B54-4D88-912A-D3825E2CE8A4@microsoft.com...
> 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




All times are GMT. The time now is 04:15 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.