title: How to deserialize a client xml of class type defined in WCF service
body: <p>I have a simple xml having only one parent node. I want to desterilize this xml to a class type, this class is defined in wcf service. The class is generated from xml using xsd.exe.</p>
  
  <p>Purpose is to - send information to wcf service in a class object form rather than xml.</p>
  
  <p>But when I use the class on client side all the property names are changed and have some suffix attached. And there are all properties set to null.</p>
  
  <p>My XML looks like -   </p>
  
  <pre><code>&lt;NafDetails xmlns="http://schemas.datacontract.org/2004/07/....Service.Contract"&gt;
    &lt;NafInfo_NafNumber&gt;&lt;/NafInfo_NafNumber&gt;
     &lt;NafInfo_CFAcctNum&gt;&lt;/NafInfo_CFAcctNum&gt;
     &lt;NafInfo_RepNum&gt;&lt;/NafInfo_RepNum&gt;
  
    &lt;NafInfo_FASIRIA&gt;0&lt;/NafInfo_FASIRIA&gt;
    &lt;NafInfo_OutsideRIA&gt;0&lt;/NafInfo_OutsideRIA&gt;
  &lt;/NafDetails&gt;
  </code></pre>
  
  <p>My deserialize method looks like </p>
  
  <pre><code>    public NafDetails Deserialize(string laserEncodedXML)
      {
          try
          {
              XDocument xDoc = XDocument.Parse(laserEncodedXML);
              var xmlSerializer = new XmlSerializer(typeof(NafDetails), "http://schemas.datacontract.org/2004/07/....Service.Contract");               
              NetDataContractSerializer obj = new NetDataContractSerializer();
              using (var xReader = xDoc.CreateReader())
              {
                 //return (NafDetails)obj.Deserialize(xReader.);
                 return (NafDetails)xmlSerializer.Deserialize(xReader);
                  //return (NafDetails)dcs.ReadObject(xReader);
              }
          }
          catch (SerializationException)
          {
              throw;
          }
          catch (Exception)
          {
              throw;
          }
      }  
  </code></pre>
  
  <p>My defined class in WCF is like - </p>
  
  <pre><code>    [Serializable, XmlRoot("NafDetails")]
      [DebuggerStepThrough]
      [XmlType(AnonymousType = true)] 
      public class NafDetails
      {
          [XmlElement("NafInfo_NafNumber")]
          public string NafInfo_NafNumber { get; set; }
          [XmlElement("NafInfo_CFAcctNum")]
          public string NafInfo_CFAcctNum { get; set; }
          [XmlElement("NafInfo_RepNum")]
          public string NafInfo_RepNum { get; set; }
          [XmlElement("NafInfo_FASIRIA")]
          public bool NafInfo_FASIRIA { get; set; }
          [XmlElement("NafInfo_OutsideRIA")]
          public bool NafInfo_OutsideRIA { get; set; }
          [XmlElement("NafInfo_DirectBusiness")]
          public bool NafInfo_DirectBusiness { get; set; }
          [XmlElement("NafInfo_CF_Pershing")]
          public bool NafInfo_CF_Pershing { get; set; }
          [XmlElement("NafInfo_CF_JPMorgan")]
          public bool NafInfo_CF_JPMorgan { get; set; }
          [XmlElement("NafInfo_DVP")]
          public bool NafInfo_DVP { get; set; }
      }
  </code></pre>
  
  <p>Please guide me to get this done. Thank you.</p>