title: XMLSerializer - how do you deserialize
body: <p>How do you deserialize this:</p>
  
  <pre><code>&lt;c:replyMessage
  xmlns:c="urn:schemas-cybersource-com:transaction-data-1.118"&gt;
       &lt;c:merchantReferenceCode&gt;cmAction12345&lt;/c:merchantReferenceCode&gt;
       &lt;c:requestID&gt;3473543574375349573452&lt;/c:requestID&gt;
       &lt;c:caseManagementActionReply&gt; 
           &lt;c:reasonCode&gt;100&lt;/c:reasonCode&gt;
       &lt;/c:caseManagementActionReply&gt; 
  &lt;/c:replyMessage&gt;
  </code></pre>
  
  <p>I get this error in fiddler response:</p>
  
  <pre><code>&lt;replyMessage xmlns='urn:schemas-cybersource-com:transaction-data-1.118'&gt; was not expected.  
  </code></pre>
  
  <p>I used binder that accepts xml on mvc action:</p>
  
  <pre><code>public class XmlModelBinderProvider : IModelBinderProvider
  {
      public IModelBinder GetBinder(Type modelType)
      {
          var contentType = System.Web.HttpContext.Current.Request.ContentType;
  
          if (string.Compare(contentType, @"text/xml",
              StringComparison.OrdinalIgnoreCase) != 0)
          {
              return null;
          }
  
          return new XmlModelBinder();
      }
  }
  
  public class XmlModelBinder : IModelBinder
  {
      public object BindModel(
          ControllerContext controllerContext,
          ModelBindingContext bindingContext)
      {
          var modelType = bindingContext.ModelType;
          var serializer = new XmlSerializer(modelType);
  
          var inputStream = controllerContext.HttpContext.Request.InputStream;
  
          return serializer.Deserialize(inputStream);
      }
  }
  </code></pre>
  
  <p>Models:</p>
  
  <pre><code>[XmlRoot("c:caseManagementActionReply")] 
  public class CCaseManagementActionReply
  {
      public string ReasonCode { get; set; }
  }
  
  [XmlRoot("c:replyMessage")] 
  public class CReplyMessage
  {
      [XmlElement(ElementName = "c:merchantReferenceCode")]
      public string MerchantReferenceCode { get; set; }
  
      [XmlElement(ElementName = "c:requestID")]
      public string RequestID { get; set; }
  
      [XmlElement(ElementName = "c:caseManagementActionReply")]
      public CCaseManagementActionReply CaseManagementActionReply { get; set; }
  }
  </code></pre>