title: ReadAsAsync Class using XmlMediaTypeFormatter or other Deserialization
body: <p>I am trying to deserialize the following XML:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;jobInfo
     xmlns="http://www.force.com/2009/06/asyncapi/dataload"&gt;
      &lt;id&gt;asjdkfljasl;kdf&lt;/id&gt;
      &lt;operation&gt;query&lt;/operation&gt;
      &lt;object&gt;jsdkfjsakldjakl&lt;/object&gt;
      ...
  &lt;/jobInfo&gt;
  </code></pre>
  
  <p>I have the following code that makes the POST request and works successfully, but cannot deserialize into my class.</p>
  
  <pre><code>client.DefaultRequestHeaders.Add("X-SFDC-Session", binding.SessionHeaderValue.sessionId);
  client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", binding.SessionHeaderValue.sessionId);
  
  var content = new StringContent(createJobXml, Encoding.UTF8, "application/xml");
  content.Headers.ContentType = new MediaTypeHeaderValue("application/xml");
  
  HttpResponseMessage response = await client.PostAsync(
      $"https://{SERVER_INSTANCE}.salesforce.com/services/async/43.0/job", content
  );
  response.EnsureSuccessStatusCode();
  
  jobInfo job = await response.Content.ReadAsAsync&lt;jobInfo &gt;(new List&lt;MediaTypeFormatter&gt;() {
      new XmlMediaTypeFormatter { UseXmlSerializer = true },
      new JsonMediaTypeFormatter()
  });
  </code></pre>
  
  <p>But I get the error </p>
  
  <blockquote>
    <p>No MediaTypeFormatter is available to read an object of type 'jobInfo ' from content with media type 'application/xml',</p>
  </blockquote>
  
  <p>my jobInfo was generated using <code>xsd.exe doc.xml</code>, <code>xsd.exe doc.xsd /classes</code></p>
  
  <pre><code>[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.6.81.0")]
  [System.SerializableAttribute()]
  [System.Diagnostics.DebuggerStepThroughAttribute()]
  [System.ComponentModel.DesignerCategoryAttribute("code")]
  [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "http://www.force.com/2009/06/asyncapi/dataload")]
  [System.Xml.Serialization.XmlRootAttribute(Namespace = "http://www.force.com/2009/06/asyncapi/dataload", IsNullable = false)]
  public partial class jobInfo
  {
      private string idField;
      private string operationField;
      private string objectField;
      ...
      public string id
      {
          get {
              return this.idField;
          }
          set {
              this.idField = value;
          }
      }
      public string operation
      {
          get {
              return this.operationField;
          }
          set {
              this.operationField = value;
          }
      }
      ...
   }
  </code></pre>
  
  <p><strong>What am I missing in order to deserialize this correctly?</strong></p>
  
  <p>This suggests that I should just read it as a string:</p>
  
  <p><a href="https://stackoverflow.com/questions/19942486/how-to-use-httpclient-to-read-an-xml-response">How to use HttpClient to read an XML response?</a></p>
  
  <p>but this suggests that it should "just work"</p>
  
  <p><a href="https://stackoverflow.com/questions/24428974/httpclient-readasasynctype-only-deserializing-part-of-the-response">HttpClient ReadAsAsync&lt;Type&gt; only deserializing part of the response</a></p>
  
  <p>I have also tried (was using class Bulkv1Job before I used xsd to convert the xml to a class)</p>
  
  <pre><code>[DataContract]
  public class Bulkv1Job
  {
      [DataMember]
      string id { get; set; }
      [DataMember]
      string operation { get; set; }
      [DataMember]
      string @object { get; set; }
      ...
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>[XmlRoot("jobInfo")]
  public class Bulkv1Job
  {
      [XmlElement("id")]
      string id { get; set; }
      [XmlElement("operation")]
      string operation { get; set; }
      ...
  }
  </code></pre>