title: Deserializing an object in a SOAP Response
body: <p>I'm trying to deserialize a SOAP response.<br>
  The soap response is like this :</p>
  
  <pre><code>&lt;soapenv:Body&gt;
        &lt;mp0:MP0123_ConnectorRequest_001_Result&gt;
           &lt;!--You have a CHOICE of the next 2 items at this level--&gt;
           &lt;mp0:result success="true"&gt;
              &lt;!--1 or more repetitions:--&gt;
              &lt;mp0:actionResult type="?" aid="?"&gt;
                 &lt;mp0:success&gt;?&lt;/mp0:success&gt;
                 &lt;!--Optional:--&gt;
                 &lt;mp0:errorMessage&gt;?&lt;/mp0:errorMessage&gt;
                 &lt;!--Zero or more repetitions:--&gt;
                 &lt;mp0:dataResult&gt;
                    &lt;!--1 or more repetitions:--&gt;
                    &lt;mp0:datafield&gt;
                       &lt;bas:name&gt;?&lt;/bas:name&gt;
                       &lt;bas:value null="false" encoding="none"&gt;?&lt;/bas:value&gt;
                    &lt;/mp0:datafield&gt;
                 &lt;/mp0:dataResult&gt;
              &lt;/mp0:actionResult&gt;
           &lt;/mp0:result&gt;
           &lt;mp0:result-in-file&gt;
              &lt;bas:ticket&gt;?&lt;/bas:ticket&gt;
              &lt;bas:members&gt;
                 &lt;!--You have a CHOICE of the next 2 items at this level--&gt;
                 &lt;bas:sequence min="?" max="?"/&gt;
                 &lt;bas:lables&gt;
                    &lt;!--1 or more repetitions:--&gt;
                    &lt;bas:fr-label aid="?"&gt;?&lt;/bas:fr-label&gt;
                 &lt;/bas:lables&gt;
              &lt;/bas:members&gt;
           &lt;/mp0:result-in-file&gt;
        &lt;/mp0:MP0123_ConnectorRequest_001_Result&gt;
     &lt;/soapenv:Body&gt;
  </code></pre>
  
  <p>The classes generated from WSDL are like this:</p>
  
  <pre><code>/// &lt;remarks/&gt;
      [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.34234")]
      [System.SerializableAttribute()]
      [System.Diagnostics.DebuggerStepThroughAttribute()]
      [System.ComponentModel.DesignerCategoryAttribute("code")]
      [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="http://schemas.datastream.net/MP_results/MP0123_001")]
      public partial class MP0123_ConnectorRequest_001_Result {
  
          private object itemField;
  
          /// &lt;remarks/&gt;
          [System.Xml.Serialization.XmlElementAttribute("result", typeof(MP0123_ConnectorRequest_001_ResultResult))]
          [System.Xml.Serialization.XmlElementAttribute("result-in-file", typeof(fileResult))]
          public object Item {
              get {
                  return this.itemField;
              }
              set {
                  this.itemField = value;
              }
          }
      }
  
     /// &lt;remarks/&gt;
      [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.34234")]
      [System.SerializableAttribute()]
      [System.Diagnostics.DebuggerStepThroughAttribute()]
      [System.ComponentModel.DesignerCategoryAttribute("code")]
      [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="http://schemas.datastream.net/MP_results/MP0123_001")]
  
  public partial class MP0123_ConnectorRequest_001_ResultResult {
  
  private MP0123_ConnectorRequest_001_ResultResultActionResult[] actionResultField;
  
  private bool successField;
  
  public MP0123_ConnectorRequest_001_ResultResult() {
      this.successField = true;
  }
  
  /// &lt;remarks/&gt;
  [System.Xml.Serialization.XmlElementAttribute("actionResult")]
  public MP0123_ConnectorRequest_001_ResultResultActionResult[] actionResult {
      get {
          return this.actionResultField;
      }
      set {
          this.actionResultField = value;
      }
  }
  
  /// &lt;remarks/&gt;
  [System.Xml.Serialization.XmlAttributeAttribute()]
  [System.ComponentModel.DefaultValueAttribute(true)]
  public bool success {
      get {
          return this.successField;
      }
      set {
          this.successField = value;
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Now I get the response by the following code, but as the only thing that I have is Response.Item which is an object I cannot deserialize it.</p>
  
  <pre><code>var response = connector.ConnectorRequestOp(Request);
  var serializer = new XmlSerializer(typeof(ConnectorRequest_001_ResultResult),"http://schemas.datastream.net/MP_results/MP0123_001");
  var  responseREsult = (MP0123_ConnectorRequest_001_ResultResult)serializer.Deserialize(new MemoryStream(response.Item));
  </code></pre>
  
  <p>I know that I cannot use <code>MemoryStream</code> in this case, so I searched a lot and read the similar posts here, but the only possible way I found was to use the path and use <code>FileStream</code> but I don't have the response path (I think). So is there any way to deserialize an object ?</p>
  
  <p>I don't know if I miss some important concepts in serialize/deserialize an soap response, as it's my first time dealing with this.</p>
  
  <p>Thanks</p>