Performance, Webservice size and Xml Namespaces

Topics: General Discussion Forum
Jun 3, 2008 at 2:49 PM
Good afternoon all,

I've been asked to look into the performance of an application built as a client factory project on top of a service factory project. Some digging revealed that I was mostly waiting for a very large set of data to be returned by a specific webservice: a response object with an array of 1600 objects, amounting to 2 Mb of xml that took 5 seconds to return from the web service server.
I turned on gzip compression for asmx files and gained about a second, turned to the xml itself, and noticed the following: the xml namespace is added as an attribute to every single element. If I would turn this off somehow, the file size would only be a third of the current 2 Mb.

Apparently the attributes are added to the xml serialization through the following 2 attributes at the top of the class generated from my xsd's:

[System.Xml.Serialization.XmlTypeAttribute(Namespace=http://ManGO_Services.DataTypes/AllVestigingen/AllVestigingen.xsd)]
[System.Xml.Serialization.XmlRootAttribute(Namespace="http://ManGO_Services.DataTypes/AllVestigingen/AllVestigingen.xsd", IsNullable=true
)]

If I remove these, I get nice, concise xml without any namespace declarations. The questions now are:
- What are the reasons that these namespaces are added like that?
- Are there any drawbacks to just removing them? My services still seem to function just fine. Is this maybe only a problem once I start mixing complex types?
- Is there a way to edit the xsd's so they generate smaller xml serializing classes? Right now I'd have to manually remove these attributes each type I generate my classes.

Thanks for any advice you can give me,


Menno van den Heuvel

 

 

Developer
Jul 8, 2008 at 12:14 AM
Edited Jul 8, 2008 at 12:21 AM
You may try using the DataContract serializer instead of the current XmlSerializer. However if that's not alowed in your contract types, then you may try read this article http://msdn.microsoft.com/en-us/magazine/cc163569.aspx or this one rather academic http://ieeexplore.ieee.org/iel5/10753/33896/01615043.pdf?isnumber=33896&prod=CNF&arnumber=1615043&arSt=+10+pp.&ared=&arAuthor=Ng%2C+A.

This one may also provide some ideas:
http://msdn.microsoft.com/en-us/library/ms172362.aspx