We are using contract first approach for WCF services in our project, XSD(s) are converted to entities using WSCF Blue and default serialization is used. The default serializer serializes the packets in following way
<category xmlns="http://myportal.com/schema/category/v1.0">
<processingDate xmlns="http://myportal.com/schema/common/elements/v1.0">0001-01-01T00:00:00</processingDate>
<key **xmlns="http://myportal.com/schema/common/elements/v1.0"**>f9a8d542-72c8-4465-8d6b-aaeb94a72394</key>
<code>C511746379</code>
<name>category308277327</name>
<description>One Tow</description>
</category>
<region xmlns="http://myportal.com/schema/shared/region/v1.0">
<key **xmlns="http://myportal.com/schema/common/elements/v1.0"**>3</key>
<code>N35</code>
<name>North</name>
<panelCode>N98</panelCode>
</region>
<category xmlns="http://myportal.com/schema/category/v1.0">
<processingDate xmlns="http://myportal.com/schema/common/elements/v1.0">0001-01-01T00:00:00</processingDate>
<key **xmlns="http://myportal.com/schema/common/elements/v1.0"**>00121be8-968f-4dbf-9d5c-d7b81e127a36</key>
<name>Aplha</name>
<code>76542</code>
<createdDate **xmlns="http://myportal.com/schema/common/elements/v1.0"**>2014-03-26T16:36:52.794876</createdDate>
<stream>Online</stream>
</category>
The problem is highlighted in bold, why the default serializer puts the whole namespace there, why can't it declare it at the top and use prefix. The whole namespace inflates size of packet.
The category entity looks like following
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.18058")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="http://myportal.com/schema/category/v1.0", TypeName="category")]
[System.Xml.Serialization.XmlRootAttribute(Namespace="http://myportal.com/schema/category/v1.0", IsNullable=false, ElementName="category")]
public partial class CategoryType : BaseType
{
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Namespace = "http://myportal.com/schema/common/elements/v1.0", Order = 0, ElementName = "key")]
public string Key
{
get
{
return this.keyField;
}
set
{
this.keyField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Order = 1, ElementName = "code")]
public string Code
{
get
{
return this.codeField;
}
set
{
this.codeField = value;
}
}
How do I enforce the XmlElementAttribute to use prefix instead of complete namespace?
Thanks,
Avi