title: HttpWebRequest - (500) Internal Server Error
body: <p>I have a SOAP Envelop logged in Database using <strong>IDispatchMessageInspector</strong>. I need to invoke my WCF Service having wsHttpBinding using the SOAP Envlope.</p>
  
  <p>I am using below code to invoke my WCF Service.</p>
  
  <pre><code>            HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create("ServiceURL");
          req.Method = "POST";
          string reqBody = theBomRequest; //it has entire soap
          byte[] reqBodyBytes = Encoding.UTF8.GetBytes(reqBody);
          req.ContentType = "application/soap+xml; charset=utf-8";
          req.GetRequestStream().Write(reqBodyBytes, 0, reqBodyBytes.Length);
          req.GetRequestStream().Close();
          HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
          Console.WriteLine("HTTP/{0} {1} {2}", resp.ProtocolVersion, (int)resp.StatusCode, resp.StatusDescription);
          if (resp.ContentLength &gt; 0)
          {
              Console.WriteLine(new StreamReader(resp.GetResponseStream()).ReadToEnd());
          }
          resp.Close(); 
  </code></pre>
  
  <p>At GetResponse, I'm getting <em>(500) Internal Server Error</em></p>
  
  <p>Thanks,
  Akif</p>