Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"The request failed with an empty response" when calling a web service

While calling a webservice hosted in a server from an aspx page am getting the error like "The request failed with an empty response".

code in my page

try {
    HttpWebRequest request1 = (HttpWebRequest)WebRequest.Create("https://login.erp.com/rodeprovisioning/provisioning.asmx");
    request1.Accept = "text/xml";
    request1.Method = "POST";
    WebProxy proxyObject = new System.Net.WebProxy("http://10.0.0.1:8080/", true);
    request1.Proxy.Credentials = CredentialCache.DefaultCredentials;
    string sReturnValue = null;
    if (string.IsNullOrEmpty(Session["Test"])) {
        sReturnValue = callservice();
        if (sReturnValue == "Success") {
            ErrorLabel.Text = sReturnValue;
            Session["Test"] = "True";
        } else {
            ErrorLabel.Text = sReturnValue;
        }
    }

} catch (Exception ex) {

}

and in web.config

<system.net>
    <authenticationModules>
      <add type = "System.Net.DigestClient" />
      <add type = "System.Net.NegotiateClient" />
      <add type = "System.Net.KerberosClient" />
      <add type = "System.Net.NtlmClient" />
      <add type = "System.Net.BasicClient" />
    </authenticationModules>
    <connectionManagement>
      <add address = "*" maxconnection = "2" />
    </connectionManagement>
    <defaultProxy>
      <proxy usesystemdefault="True"   bypassonlocal = "True"   />
    </defaultProxy>
    <webRequestModules>
      <add prefix = "http"   type = "System.Net.HttpRequestCreator"        />
      <add prefix = "https"  type = "System.Net.HttpRequestCreator"        />
      <add prefix = "file"   type = "System.Net.FileWebRequestCreator"         />
    </webRequestModules>
  </system.net>

Is it a firewall problem.Any Suggestion?

like image 717
bala3569 Avatar asked Dec 27 '11 08:12

bala3569


1 Answers

I know this is an old question, but we had the same exception happening in one of our integration environments:

System.Net.WebException: The request failed with an empty response

The issue was that when we upgraded the server hardware, we also switched all of our endpoints to be using HTTPS. The code that was calling the endpoints was not upgraded, so it was still using regular HTTP. Apparently this is the exception you get when you try to call an HTTPS service as HTTP. Hope this helps someone down the line.

like image 54
Andacious Avatar answered Sep 28 '22 06:09

Andacious