title: HttpClient & SOAP (C#)
body: <p>I'm trying to use the HttpClient class to send a SOAP message:</p>
  <p>Doing so with REST seems easy (code from <a href="http://debugmode.net/2012/03/07/consuming-asp-net-web-api-service-using-httpclient-part2-of-many/" rel="nofollow noreferrer">here</a>) :</p>
  <pre><code>using System;
  using System.Net.Http;
  using System.Json;
  
  namespace ConsoleApplication39
  {
  class Program
  {
  static void Main(string[] args)
  {
  
  HttpClient proxy = new HttpClient();
  proxy.GetAsync(&quot;http://localhost:14892/api/Bloggers&quot;).ContinueWith((r) =&gt;
  {
  HttpResponseMessage response = r.Result;
  response.Content.ReadAsAsync&lt;JsonArray&gt;().ContinueWith(
  (a)=&gt;
  {
  foreach(var w in a.Result)
  {
  Console.WriteLine(w.ValueOrDefault(&quot;Name&quot;).ToString());
  Console.WriteLine(w.ValueOrDefault(&quot;Intrest&quot;).ToString());
  }
  });
  
  });
  
  Console.ReadKey(true);
  
  }
  
  }
  }
  </code></pre>
  <p>I would like to do something similar with SOAP.</p>
  <p>I have the host (<a href="http://opensearch.addi.dk/2.2/" rel="nofollow noreferrer">http://opensearch.addi.dk/2.2/</a>)
  and the SOAP message to POST:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;SOAP-ENV:Envelope xmlns:SOAP-ENV=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot; xmlns:ns1=&quot;http://oss.dbc.dk/ns/opensearch&quot;&gt;
    &lt;SOAP-ENV:Body&gt;
      &lt;ns1:searchRequest&gt;
        &lt;ns1:query&gt;dc.title=zorro AND dc.type=bog&lt;/ns1:query&gt;
        &lt;ns1:agency&gt;100200&lt;/ns1:agency&gt;
        &lt;ns1:profile&gt;test&lt;/ns1:profile&gt;
        &lt;ns1:start&gt;1&lt;/ns1:start&gt;
        &lt;ns1:stepValue&gt;10&lt;/ns1:stepValue&gt;
      &lt;/ns1:searchRequest&gt;
    &lt;/SOAP-ENV:Body&gt;
  &lt;/SOAP-ENV:Envelope&gt;
  </code></pre>
  <p>... but how to send it ?</p>
  <p>I'll admit that this is the first SOAP Web Service I have ever used so I may have no idea what I'm doing, but in its simplest form could it be something like :</p>
  <pre><code>HttpClient hc = new HttpClient();
  hc.BaseAddress = new Uri(&quot;http://opensearch.addi.dk/2.2/&quot;);
      
  HttpContent content = *... something*
      
  HttpResponseMessage rm = await hc.PostAsync(&quot;http://opensearch.addi.dk/2.2/&quot;, content);
  </code></pre>
  <p>I assume that the SOAP message should somehow be created through a HttpContent static method like HttpContent.Create(..) but I can't get that to work ...</p>
  <p>I know this is a dumb question but I still need help :) !</p>
  <p>tia ...</p>