title: Unable to deserialize XML post to WCF service. What am I missing?
body: <p>I have this class which is an input to my WCF service:</p>
  
  <pre><code>[DataContract]
  public class LoginDTO
  {
      [DataMember]
      public string Username { get; set; }
  
      [DataMember]
      public string Password { get; set; }
  }
  </code></pre>
  
  <p>And here is the method in my service interface (IUserServices):</p>
  
  <pre><code>    [OperationContract]
      [FaultContract(typeof(ServiceException))]
      [ServiceKnownType(typeof(LoginDTO))]
      [WebInvoke(UriTemplate = "/login/", Method = "POST")]
      UserDTO LogIn(LoginDTO loginInfo);
  </code></pre>
  
  <p>Testing my service (using Postman) causes this error:</p>
  
  <blockquote>
    <p>System.Runtime.Serialization.SerializationException: Unable to
    deserialize XML body with root name 'LoginDTO' and root namespace ''
    (for operation 'LogIn' and contract ('IUserServices', 
    '<a href="http://tempuri.org/" rel="nofollow noreferrer">http://tempuri.org/</a>')) using DataContractSerializer. Ensure that the
    type corresponding to the XML is added to the known types collection
    of the service.</p>
  </blockquote>
  
  <p>And I post this: (Content-Type => application/xml)</p>
  
  <pre><code>&lt;LoginDTO&gt;
      &lt;Username&gt;MyUsername&lt;/Username&gt;
      &lt;Password&gt;MyPassword&lt;/Password&gt;
  &lt;/LoginDTO&gt;
  </code></pre>
  
  <p>What am I missing, or what am I doing wrong?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I marked @knyu's reply below as the answer because it addresses my immediate question. However, I decided to use a (proper) namespace for my types, so I added the <a href="https://stackoverflow.com/questions/3408461/setting-wcf-datacontract-namespace-using-contractnamespace-attribute">ContractNamespace</a> attribute on my assembly that contains my DTOs. This then meant that my input XML will need to specify this namespace to be properly deserialized.</p>