16

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?

4
  • 1
    Have you tried using Wireshark to find out what's happening at the HTTP level?
    – Jon Skeet
    Dec 27, 2011 at 8:18
  • 4
    Then I suggest that should be your next step. There's no point in trying to debug the client if it's a server-side issue or vice versa.
    – Jon Skeet
    Dec 27, 2011 at 8:30
  • 1
    The error "The request failed with an empty response" is a clear indication you should start debugging on the server side instead of the client side. Unhandled exceptions on the server can actually cause this error to occur. Using network sniffers might not even be enough. Dec 27, 2011 at 11:25
  • 1
    I just debugged a similar issue on our site, and it is because our load balancer was responding with a redirect for any non https URL. Our client code wasn't handling this correctly, so we received this response. I know this is an old question and you are already using HTTPS, but maybe it is/was something similar. By all means, update your question with your findings to maybe help other people in a similar situation.
    – Mr Moose
    Feb 13, 2013 at 1:13

5 Answers 5

40

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.

0
7

I would like to add to what Andacious stated. I was making a call to a web-service which was https but when I looked at the properties of the object making the call it actually was using http. So I specifically set the URL property.

I have a class called interchange which inherits from SoapHttpClientProtocol.

interchangeWS = new InterchangeWS();
interchangeWS.Url = "https://somesite/interchange.asmx";

string x = interchangeWS.SomeMethod("someParameter");
3

Sometimes it happens when pointing to an endpoint which is under LoadBalancer, what's happens is once you add the reference to the project (in VisualStudio) using HTTPS, then check the app.config file under the child and see if the endpoint URL is set to HTTP, then update it manually to HTTPS and you should be good. Hope it helps.

1

make sure that service is https instead of http.Place https in web.config file also

0
-1

In client app.config or web.config first check web service URL , if your web Service URL having Secure Sockets Layer certificate , then add same Secure Sockets Layer enable URL to app.config or web.config . Like this "https://crm.XXXX.com/webServiceName.asmx"

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

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.