title: XmlSerializer Deserialize failures
body: <p>I have wsdl from third party server.  Ran svcutil and ended up wih a set of </p>
  
  <pre><code>XmlNode AMethod(object Request);
  </code></pre>
  
  <p>methods.  There is a separate 100 page pdf describing response/request objects for each method</p>
  
  <p>My thought was wrap web methods and use XmlSerializer  to return strongly typed objects.  Returned xml looks like this (i removed soap headers):</p>
  
  <pre><code>&lt;Response xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
          xsi:type="ResponseExt" 
          xmlns="http://www.thirdparty.com/lr/"&gt;
    &lt;Code&gt;0&lt;/Code&gt;
    &lt;Message&gt;SUCCESS&lt;/Message&gt;
    &lt;SessionId&gt;session_token&lt;/SessionId&gt;
  &lt;/Response&gt;
  </code></pre>
  
  <p>Looked simple.  Created a class(from document/wire captures):</p>
  
  <pre><code>[XmlRoot("Response")]
  //EDIT added XmlType
  [XmlType("ResponseExt", Namespace = "http://www.thirdparty.com/lr/")]
  public class MyClass {
      public string Code {get; set;}
      public string Message {get; set;}
      public string SessionId {get; set;}
  }
  </code></pre>
  
  <p>Processing time:</p>
  
  <pre><code>//XmlNode node = xml from above
  XmlSerializer serializer = new XmlSerializer(typeof(MyClass));
  XmlNodeReader reader =  new XmlNodeReader(node);
  Myclass myclass = serializer.Deserialize(reader) as MyClass
  </code></pre>
  
  <p>Last line is where it blows up with inner exception message: <strong>The specified type was not recognized: name='ResponseExt', namespace='<a href="http://www.thirdparty.com/lr/" rel="nofollow noreferrer">http://www.thirdparty.com/lr/</a>', at <code>&lt;Response xmlns=''</code>>.</strong><br>
  I can't figure out how to make Serializer happy and what exactly these two mean</p>
  
  <blockquote>
    <p>xsi:type="ResponseExt"
    xmlns="http://www.thirdparty.com/lr/</p>
  </blockquote>
  
  <p>As always any advice and pointer are appreciated</p>
  
  <hr>
  
  <p>EDIT: Accepted answer below.</p>
  
  <p>I was still getting exception, until i found this, hopefully it'll save someone some time.
  I started to work backwards.  Captured xml on the wire. Deserialized to my created classes with correct attributes: worked like a charm.  Tried again from webservice - exception.  For some reason XmlSerializer doesn't recognize ResponseExt.</p>
  
  <pre><code>XmlSerializer serializer = new XmlSerializer(typeof(Response));
  XmlNode node = (XmlNode)results[0];
  XmlDocument doc = new XmlDocument();
  doc.LoadXml(node.OuterXml); //reload node
  XmlNodeReader reader = new XmlNodeReader(doc.FirstChild); //there is only one node
  Response rsp = serializer.Deserialize(reader) as Response; //works
  </code></pre>
  
  <p>EDIT:  underlying issue wsdl file was not complete.  After spending 2 days on this and finding this (ugly) workaround, third-party vendor provided <strong>complete</strong> WSDL with all types that deserialize without errors.</p>