title: Consuming SOAP web service in ASP.NET
body: <p>I have a SOAP WSDL (found here: <a href="https://portal.bsh-partner.com/picenter/server/a2a/" rel="nofollow noreferrer">https://portal.bsh-partner.com/picenter/server/a2a/</a>) and I am trying to consume the web services.</p>
  
  <pre><code>var soapEnvelope = string.Empty;
  soapEnvelope = "&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;";
  soapEnvelope += "&lt;soapenv:Envelope xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:q0=\"http://thexmlhost.com\"&gt;";
  soapEnvelope += "&lt;q0:Connect&gt;";
  soapEnvelope += "&lt;q0:Username&gt;username&lt;/q0:Username&gt;";
  soapEnvelope += "&lt;q0:Password&gt;password&lt;/q0:Password&gt;";
  soapEnvelope += "&lt;/q0:Connect&gt;";
  soapEnvelope += "&lt;/soapenv:Body&gt;";
  soapEnvelope += "&lt;/soapenv:Envelope&gt;";
  
  var xmlHttp = new MSXML2.ServerXMLHTTP40();
  xmlHttp.open("POST", "https://thexmlhost.com/", "", "");
  xmlHttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
  xmlHttp.setRequestHeader("SOAPAction", "thexmlhost.com/");
  
  xmlHttp.send(soapEnvelope);
  
  xmlHttp.waitForResponse(500);
  
  var outXml = xmlHttp.responseText;
  </code></pre>
  
  <p>The response keeps returning a general HTTP response error page.  Any idea how I should be passing my Soap Envelope to get the proper response back from the web service?</p>