title: Read SOAP xml response from ASP.NET Core [MTOM not working]
body: <p>I'm using an ASP.NET Core service to call a SOAP server. I can't use the web.config as in the linked question, since I don't have it.</p>
  
  <p>I'm able to call it and receive the correct response. My problem now is to find a smart method to read it; I'm going to explain.</p>
  
  <p>My response, for example, is:</p>
  
  <pre><code>--MIMEBoundary_59f98a3b863640e46b622e5739083846dab4b1825abc60d0
  Content-Type: application/xop+xml; charset=UTF-8; type="text/xml"
  Content-Transfer-Encoding: binary
  Content-ID: 
  &lt;0.49f98a3b863640e46b622e5739083846dab4b1825abc60d0@apache.org&gt;
  
  
  --MIMEBoundary_59f98a3b863640e46b622e5739083846dab4b1825abc60d0--
  
  &lt;ns2:res xmlns:ns2="http:/xxxxx/v1.0/types"&gt;
      &lt;ID&gt;1162898&lt;/ID&gt;
      &lt;DataOraRicezione&gt;2018-03-13T15:08:30.119+01:00&lt;/DataOraRicezione&gt;
  &lt;/ns2:res&gt;
  </code></pre>
  
  <p>I have this xml in a string and I'd like to parse it in my class. I can do it, but the problem is the MIME boundary. Obviously, that part makes my string a NOT valid xml, so I have to avoid it. I can just parse my string and delete the first part with some string management, but this is a really bad solution.</p>
  
  <p>Since I'm quite a dummy with SOAP, probably there are some ways I don't know.</p>
  
  <p>The code I use to call the SOAP is:</p>
  
  <pre><code>var request = CreateWebRequest(url, x509);
  byte[] bytes;
  bytes = Encoding.ASCII.GetBytes(xmlContent);
  request.ContentType = "application/xml; encoding='utf-8'";
  request.ContentLength = bytes.Length;
  Stream requestStream = request.GetRequestStream();
  requestStream.Write(bytes, 0, bytes.Length);
  requestStream.Close();
  HttpWebResponse response;
  response = (HttpWebResponse)request.GetResponse();
  if (response.StatusCode == HttpStatusCode.OK)
  {
      Stream responseStream = response.GetResponseStream();
      string responseStr = new StreamReader(responseStream).ReadToEnd();
      return responseStr;
  }
  </code></pre>
  
  <p>I tried this to manage the MTOM </p>
  
  <pre><code>XmlDictionaryReader mtomReader = XmlDictionaryReader.CreateMtomReader(responseStream, Encoding.UTF8, XmlDictionaryReaderQuotas.Max);
  </code></pre>
  
  <p>but I got the message: <strong>The Message Transmission Optimization Mechanism (MTOM) message encoding is not supported on this platform.</strong></p>
  
  <p>So, I'm searching for an alternative valid for ASP.NET CORE</p>