title: HTTP Web request 500 Internal Server error?
body: <p>Am making a call to  a webservice but i get SOAPException error responds "The remote server returned an error: (500) Internal Server Error" but when I use Wireshark or Fiddler I get Status error,status code and status description of the error not "The remote server returned an error: (500) Internal Server Error".
  How can I get these error information as well directly from vb2010 </p>
  
  <pre><code>Sub readsoap()
  
      Dim webRequest As HttpWebRequest
      'Dim reader As StreamReader
      Dim response As HttpWebResponse = Nothing
      Dim result As String
      Dim data As String = ""
      Dim url As String = ""
      Dim xdoc As New XmlDocument
      result = ""
      TextBox1.Text = ""
      Dim xml As String = ""
  
      xml = "&lt;soapenv:Envelope xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:v1=""http://xmlns.bb.com/Request/V1"" xmlns:v3=""http://xmlns.bb.com/RequestHeader/V3"" xmlns:v2=""http://xmlns.bb.com/ParameterType/V2""&gt;" _
      &amp; "&lt;soapenv:Header xmlns:wsse=""http://aaa.bb-open.org/wss/2004/01/aaa-200401-wss-wssecurity-secext-1.0.xsd""&gt;" _
        &amp; "&lt;wsse:Security&gt;" _
           &amp; "&lt;wsse:UsernameToken&gt;" _
              &amp; "&lt;wsse:Username&gt;{8}&lt;/wsse:Username&gt;" _
              &amp; "&lt;wsse:Password&gt;{9}&lt;/wsse:Password&gt;" _
           &amp; "&lt;/wsse:UsernameToken&gt;" _
        &amp; "&lt;/wsse:Security&gt;" _
     &amp; "&lt;/soapenv:Header&gt;" _
               &amp; "&lt;soapenv:Body&gt;" _
                &amp; "&lt;v1:BRequest&gt;" _
                 &amp; "&lt;v3:RequestHeader&gt;" _
                  &amp; "&lt;v3:Information&gt;" _
                   &amp; "&lt;v3:ID&gt;{0}&lt;/v3:ID&gt;" _
                   &amp; "&lt;!--Optional:--&gt;" _
                   &amp; "&lt;v3:traID&gt;&lt;/v3:traID&gt;" _
                   &amp; "&lt;v3:count&gt;R&lt;/v3:coun&gt;" _
                   &amp; "&lt;v3:corID&gt;3465FGFRwsdss&lt;/v3:corID&gt;" _
                  &amp; "&lt;/v3:Information&gt;" _
                 &amp; "&lt;/v3:RequestHeader&gt;" _
                 &amp; "&lt;v1:requestBody&gt;" _
                  &amp; "&lt;v1:action&gt;{10}&lt;/v1:action&gt;" _
                  &amp; "&lt;!--Optional:--&gt;" _
                  &amp; "&lt;v1:deb&gt;{1}&lt;/v1:deb&gt;" _
                  &amp; "&lt;v1:cre&gt;{2}&lt;/v1:cre&gt;" _
                  &amp; "&lt;v1:am&gt;{3}&lt;/v1:am&gt;" _
                  &amp; "&lt;!--Optional:--&gt;" _
                  &amp; "&lt;v1:tId&gt;&lt;/v1:tId&gt;" _
                  &amp; "&lt;!--Optional:--&gt;" _
                  &amp; "&lt;v1:inId&gt;&lt;/v1:inId&gt;" _
                  &amp; "&lt;!--Optional:--&gt;" _
                  &amp; "&lt;v1:addiParam&gt;" _
                   &amp; "&lt;v2:ParameterType&gt;" _
                    &amp; "&lt;v2:parameterName&gt;{4}&lt;/v2:parameterName&gt;" _
                    &amp; "&lt;v2:parameterValue&gt;{5}&lt;/v2:parameterValue&gt;" _
                   &amp; "&lt;/v2:ParameterType&gt;" _
                   &amp; "&lt;v2:ParameterType&gt;" _
                    &amp; "&lt;v2:parameterName&gt;{6}&lt;/v2:parameterName&gt;" _
                    &amp; "&lt;v2:parameterValue&gt;{7}&lt;/v2:parameterValue&gt;" _
                   &amp; "&lt;/v2:ParameterType&gt;" _
                  &amp; "&lt;/v1:addiParameters&gt;" _
                 &amp; "&lt;/v1:requestBody&gt;" _
                &amp; "&lt;/v1:BRequest&gt;" _
               &amp; "&lt;/soapenv:Body&gt;" _
              &amp; "&lt;/soapenv:Envelope&gt;"
  
      url = "http://123.456.78.5548:5545/abc/serv/custinfo"
      webRequest = DirectCast(System.Net.WebRequest.Create(url), HttpWebRequest)
      webRequest.Method = "POST"
      webRequest.UseDefaultCredentials = False
      webRequest.Proxy = CType(Nothing, IWebProxy)
      webRequest.ContentType = "application/x-www-form-urlencoded"
      Dim postdata As String = String.Format(xml, "req", "123", "443", 100, "wedge", "0002", "con", "Prep", "", "", "")
      webRequest.ContentLength = postdata.Length
      webRequest.KeepAlive = True
  
      'Try
      Dim writer As New StreamWriter(webRequest.GetRequestStream(), System.Text.Encoding.ASCII)
      writer.Write(postdata)
      writer.Close()
      response = DirectCast(webRequest.GetResponse(), HttpWebResponse)
      If response.StatusCode = HttpStatusCode.OK Then
          xdoc.Load(webRequest.GetResponse().GetResponseStream()) ' Fast
          txtResponse.Text = xdoc.InnerText
      End If
  
      'Catch ex As Exception
      'txtResponse.Text = ex.Message
      ' End Try
  End Sub
  </code></pre>