title: .NET Xml deserialization, issue/error with xsi:type attribute
body: <p>VS2008, .NET Framework 3.5</p>
  
  <p>We're utilizing the WebEx Xml API.  Here's a sample Xml response from their web service that I'm trying to deserialize into .NET classes.  </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;serv:message xmlns:serv="http://www.webex.com/schemas/2002/06/service" xmlns:com="http://www.webex.com/schemas/2002/06/common" 
  
  xmlns:event="http://www.webex.com/schemas/2002/06/service/event"&gt;&lt;serv:header&gt;&lt;serv:response&gt;&lt;serv:result&gt;SUCCESS&lt;/serv:result&gt;&lt;serv:gsbStatus&gt;PRIMARY&lt;/s
  
  erv:gsbStatus&gt;&lt;/serv:response&gt;&lt;/serv:header&gt;
  &lt;serv:body&gt;
  &lt;serv:bodyContent xsi:type="event:lstsummaryEventResponse" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
  &lt;event:matchingRecords&gt;
      &lt;serv:total&gt;2&lt;/serv:total&gt;
      &lt;serv:returned&gt;2&lt;/serv:returned&gt;
      &lt;serv:startFrom&gt;1&lt;/serv:startFrom&gt;
  &lt;/event:matchingRecords&gt;
  &lt;event:event&gt;
      &lt;event:sessionKey&gt;999999&lt;/event:sessionKey&gt;
      &lt;event:sessionName&gt;Test Event 1&lt;/event:sessionName&gt;
      &lt;event:sessionType&gt;129&lt;/event:sessionType&gt;
      &lt;event:hostWebExID&gt;SomeName&lt;/event:hostWebExID&gt;
      &lt;event:startDate&gt;03/28/2012 14:30:00&lt;/event:startDate&gt;
      &lt;event:endDate&gt;03/28/2012 14:45:00&lt;/event:endDate&gt;
      &lt;event:timeZoneID&gt;11&lt;/event:timeZoneID&gt;
      &lt;event:duration&gt;15&lt;/event:duration&gt;
      &lt;event:description&gt;&lt;/event:description&gt;
      &lt;event:status&gt;NOT_INPROGRESS&lt;/event:status&gt;
      &lt;event:panelists&gt;&lt;/event:panelists&gt;
      &lt;event:listStatus&gt;PUBLIC&lt;/event:listStatus&gt;
  &lt;/event:event&gt;
  &lt;/serv:bodyContent&gt;
  &lt;/serv:body&gt;
  &lt;/serv:message&gt;
  </code></pre>
  
  <p>Here's the class that we're deserializing into:</p>
  
  <pre><code>using System;
  using System.Xml;
  using System.Xml.Serialization;
  using System.Xml.Schema;
  using System.Collections.Generic;
  
  namespace Masonite.MTier.WebEx
  {
      [Serializable()]
      [XmlRoot("message", Namespace = "http://www.webex.com/schemas/2002/06/service")]
      public class lstsummaryEventResponsexx
      {
          [XmlNamespaceDeclarations]
          public XmlSerializerNamespaces xmlns = new XmlSerializerNamespaces();
  
          public lstsummaryEventResponsexx()
          {
              xmlns.Add("serv", "http://www.webex.com/schemas/2002/06/service");
              xmlns.Add("com", "http://www.webex.com/schemas/2002/06/common");
              xmlns.Add("event", "http://www.webex.com/schemas/2002/06/service/event");
          }
  
  
          [XmlElement(ElementName = "header")]
          public Header header { get; set; }
  
          [XmlElement(ElementName = "body")]
          public Body body { get; set; }
  
  
          [Serializable()]
          [XmlRoot("header")]
          public class Header
          {
              [XmlElement(ElementName = "response")]
              public Response response { get; set; }
          }
  
  
          [Serializable()]
          [XmlRoot("body")]
          [XmlInclude(typeof(lstsummaryEventResponse))]
          public class Body
          {
              [XmlElement(ElementName = "bodyContent", Form = XmlSchemaForm.Qualified)]
              public BodyContent bodyContent { get; set; }
          }
  
          [Serializable()]
          public class lstsummaryEventResponse
          {
  
          }
  
          [Serializable()]
          [XmlRoot("response")]
          public class Response
          {
              [XmlElement(ElementName = "result")]
              public string result { get; set; }
  
              [XmlElement(ElementName = "reason")]
              public string reason { get; set; }
  
              [XmlElement(ElementName = "gsbStatus")]
              public string gsbStatus { get; set; }
  
              [XmlElement(ElementName = "exceptionID")]
              public string exceptionID { get; set; }
          }
  
  
          [Serializable()]
          [XmlRoot("bodyContent")]
          public class BodyContent
          {            
              [XmlElement(ElementName = "matchingRecords", Namespace = "http://www.webex.com/schemas/2002/06/service/event")]
              public MatchingRecords matchingRecords { get; set; }
  
              [XmlElement(ElementName = "event", Namespace = "http://www.webex.com/schemas/2002/06/service/event")]
              public List&lt;EventSummary&gt; events { get; set; }
          }
  
  
          [Serializable()]
          [XmlRoot("matchingRecords")]
          public class MatchingRecords
          {
              [XmlElement(ElementName = "total", Namespace = "http://www.webex.com/schemas/2002/06/service")]
              public int total { get; set; }
  
              [XmlElement(ElementName = "returned", Namespace = "http://www.webex.com/schemas/2002/06/service")]
              public int returned { get; set; }
  
              [XmlElement(ElementName = "startFrom", Namespace = "http://www.webex.com/schemas/2002/06/service")]
              public int startFrom { get; set; }
          }
  
  
          [Serializable()]
          [XmlRoot("event")]
          public class EventSummary
          {
              [XmlElement(ElementName = "sessionKey")]
              public long sessionKey { get; set; }
  
              [XmlElement(ElementName = "sessionName")]
              public string sessionName { get; set; }
  
              [XmlElement(ElementName = "sessionType")]
              public int sessionType { get; set; }
  
              [XmlElement(ElementName = "hostWebExID")]
              public string hostWebExID { get; set; }
  
              [XmlElement(ElementName = "startDate")]
              public string startDate { get; set; }
  
              [XmlElement(ElementName = "endDate")]
              public string endDate { get; set; }
  
              [XmlElement(ElementName = "timeZoneID")]
              public int timeZoneID { get; set; }
  
              [XmlElement(ElementName = "duration")]
              public int duration { get; set; }
  
              [XmlElement(ElementName = "description")]
              public string description { get; set; }
  
              [XmlElement(ElementName = "status")]
              public string status { get; set; }
  
              [XmlElement(ElementName = "panelists")]
              public string panelists { get; set; }
  
              [XmlElement(ElementName = "listStatus")]
              public listingType listStatus { get; set; }
          }
      }
  }
  </code></pre>
  
  <p>The error I'm receiving:  </p>
  
  <pre><code>The specified type was not recognized: name='lstsummaryEventResponse', namespace='http://www.webex.com/schemas/2002/06/service/event', at &lt;bodyContent xmlns='http://www.webex.com/schemas/2002/06/service'&gt;  
  </code></pre>
  
  <p>I'm not sure how to provide the type lstsummaryEventResponse for the Deserialize method.  I added another serializable class to my class above using that name, but get the same error.  Any thoughts?  </p>