title: Omitting xsi and xid namespaces while serializing an object in .Net using data attributes
body: <p>I have already visited <a href="https://stackoverflow.com/questions/258960/how-to-serialize-an-object-to-xml-without-getting-xmlns">this</a> post but it is not helpful as I do not have control over serialization. </p>
  
  <p><strong>Background:</strong> I have a WSDL document which I have added as a web reference and got a reference.cs class. I am calling a service from .Net application but it is throwing an error while deserializing. Following are my XML files one which works fine and other which is giving me an error.</p>
  
  <p><strong>Works fine:</strong></p>
  
  <pre><code>&lt;soapenv:Envelope
      xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
      xmlns:mas="http://orgname.com/compxref/Sometype"&gt;
      &lt;soapenv:Header/&gt;
      &lt;soapenv:Body&gt;
          &lt;mas:SomeInputType&gt; 
      ...............
  </code></pre>
  
  <p><strong>Throwing Error:</strong> </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;soap:Envelope
      xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
      &lt;soap:Body&gt;
          &lt;SomeInputType
              xmlns="http://orgname.com/compxref/Sometype"&gt;
      .........................
  </code></pre>
  
  <p>My serialization class looks like below:</p>
  
  <pre><code>[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.7.2612.0")]
  [System.SerializableAttribute()]
  [System.Diagnostics.DebuggerStepThroughAttribute()]
  [System.ComponentModel.DesignerCategoryAttribute("code")]    [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://orgname.com/compxref/Sometype")]
  
  public partial class SomeInputType
  {
      ...All the properties
  }
  </code></pre>
  
  <p>Question: I want to change this XML to look like the one which is working fine. But here, I do not have control on serialization or deserialization. All I can do is to decorate Class and properties using data attributes.</p>