title: Deserialize a soap message
body: <p>i have one provider extern that send me that xml for test</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
                 xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
  &lt;soap:Header&gt;
     &lt;AVCabeza transactionID="000032" xmlns="http://webservices.patito/Core/"&gt;
     &lt;Solicitor entityID="WEST" systemType="WEB" /&gt;   
    &lt;/AVCabeza&gt;
  &lt;/soap:Header&gt;
  &lt;soap:Body&gt;
      &lt;Availability xmlns:a="http://webservices.patito/Availability/" 
        xmlns:hc="http://webservices.patito/Common/" summaryOnly="true" 
        xmlns="http://webservices.patito/og/Availability.wsdl"&gt;
       &lt;a:AvailabilityDetail availReqType="Room"&gt;
         &lt;a:Estadia&gt;
          &lt;hc:StartDate&gt;2009-01-05T00:00:00.0000000-05:00&lt;/hc:StartDate&gt;
            &lt;hc:EndDate&gt;2009-01-06T00:00:00.0000000-05:00&lt;/hc:EndDate&gt;
         &lt;/a:Estadia&gt;
         &lt;a:HotelSearchCriteria&gt;              
              &lt;a:HotelRef chainCode="WC"/&gt;            
         &lt;/a:HotelSearchCriteria&gt;
        &lt;/a:AvailabilityDetail&gt;
       &lt;/Availability&gt;
    &lt;/soap:Body&gt;
  &lt;/soap:Envelope&gt;
  </code></pre>
  
  <p>I want deserializer so i did it</p>
  
  <p>1) i used the xsd for generate c# class</p>
  
  <p>2) Create a new project class library with the class generate.  </p>
  
  <p>The structure </p>
  
  <p>WebServicesExterns (Project)
       --> Services (Folder)
          ---> all class</p>
  
  <p>example</p>
  
  <pre><code>namespace WebServicesExterns.Services
  
  &lt;System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42"), _
   System.SerializableAttribute(), _
   System.Diagnostics.DebuggerStepThroughAttribute(), _
   System.ComponentModel.DesignerCategoryAttribute("code"), _
   System.Xml.Serialization.XmlTypeAttribute([Namespace]:="http://webservices.patito/Availability.wsdl")&gt; _
  Partial Public Class Availability
  
  
  
  
  '''&lt;comentarios/&gt;
  &lt;System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42"),  _
  System.SerializableAttribute(),  _
  System.Diagnostics.DebuggerStepThroughAttribute(),  _
  System.ComponentModel.DesignerCategoryAttribute("code"),  _
  System.Xml.Serialization.XmlTypeAttribute([Namespace]:="http://webservices.patito/Core/"),  _
  System.Xml.Serialization.XmlRootAttribute([Namespace]:="http://webservices.patito/Core/", IsNullable:=false)&gt;  _
  Partial Public Class AVCabeza
  </code></pre>
  
  <p>3) After create a test class for try deserializer</p>
  
  <pre><code>using WebServicesExterns.Services;
  using System;
  using System.Collections;
  using System.IO;
  using System.Linq;
  using System.Runtime.Remoting;
  using System.Runtime.Serialization;
  using System.Xml;
  using System.Xml.Serialization;
  using NUnit.Framework;
  using System.Reflection;
  using System.Runtime.Serialization.Formatters.Soap;
  
  
      [Test()]
      public void ShouldDeserializerSoapMessage()
      {
          var message = SoapToFromFile(@"C:\rq\Availability.xml");
          Assert.IsNotNull(message);
      }
  
  
      public object SoapToFromFile(string filePath)
      {
          IFormatter formatter;
          FileStream fileStream = null;
          Object objectFromSoap = null;            
  
          try
          {
              fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read);
              formatter = new SoapFormatter();
              objectFromSoap = formatter.Deserialize(fileStream);
          }
          catch (Exception exception)
          {
              throw exception;
          }
          finally
          {
              if (fileStream != null) fileStream.Close();
          }
          return objectFromSoap;
      }
  </code></pre>
  
  <p>So, return that error</p>
  
  <p>Parse Error, no assembly associated with Xml key "AVCabeza" "_P1"</p>
  
  <p>Debugging i founded what _P1 is equal to "http://webservices.patito/Core/"</p>
  
  <p>Apparently not found "Type" AVCabeza class</p>
  
  <p>What's wrong?</p>
  
  <p><strong>New update</strong></p>
  
  <p>Look that was the provider give me</p>
  
  <p>one folder with that structure</p>
  
  <pre><code>root
  |
  --  WSDL_XSD
  |    |-XSD
  |    |   files with extension .xsd
  |    | 
  |    --WS
  |        files with extension .wsdl
  |-- XMLSamples
       |-files with xml extension that contain soap messsages
  </code></pre>
  
  <p>well i delete of the xml (previous example) the head </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;Availability xmlns:a="http://webservices.patito/Availability/" 
        xmlns:hc="http://webservices.patito/Common/" summaryOnly="true" 
        xmlns="http://webservices.patito/og/Availability.wsdl"&gt;
       &lt;a:AvailabilityDetail availReqType="Room"&gt;
         &lt;a:Estadia&gt;
          &lt;hc:StartDate&gt;2009-01-05T00:00:00.0000000-05:00&lt;/hc:StartDate&gt;
            &lt;hc:EndDate&gt;2009-01-06T00:00:00.0000000-05:00&lt;/hc:EndDate&gt;
         &lt;/a:Estadia&gt;
         &lt;a:HotelSearchCriteria&gt;              
              &lt;a:HotelRef chainCode="WC"/&gt;            
         &lt;/a:HotelSearchCriteria&gt;
        &lt;/a:AvailabilityDetail&gt;
  &lt;/Availability&gt;
  </code></pre>
  
  <p>and will try get deserializable availability object but fail this mark </p>
  
  <pre><code>not expected "&lt;Availability .."
  </code></pre>
  
  <p>now in wsdl_xsd -> ws -> ws  i see the availability exists so i think what availability is wrap to availabilitydetail (real request) which is the object i cant delete
  availability  tag because it have namespace spacefications for childs tags</p>
  
  <p>what think about it?</p>
  
  <p>maybe if i delete availability and insert namespaces (somehow) i could get my de-serializer object</p>