2011-12-27 37 views
5

Mentre si chiama un servizio Web ospitato in un server da una pagina di aspx viene visualizzato l'errore "Richiesta non riuscita con una risposta vuota"."Richiesta non riuscita con risposta vuota" quando si chiama un servizio Web

codice

nella mia pagina

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) { 

} 

e nel 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> 

E 'un firewall problem.Any suggerimento?

+1

Hai provato a utilizzare Wireshark per scoprire cosa sta accadendo a livello HTTP? –

+0

No jon non ho ... – bala3569

+4

Quindi suggerisco che dovrebbe essere il tuo prossimo passo. Non ha senso provare a eseguire il debug del client se si tratta di un problema lato server o viceversa. –

risposta

15

So che questa è una vecchia questione, ma abbiamo avuto la stessa eccezione accadendo in uno dei nostri ambienti di integrazione:

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

Il problema era che quando abbiamo aggiornato l'hardware del server, abbiamo anche acceso tutta la nostra endpoint che utilizzano HTTPS. Il codice che stava chiamando gli endpoint non è stato aggiornato, quindi utilizzava regolarmente HTTP. Apparentemente questa è l'eccezione che si ottiene quando si tenta di chiamare un servizio HTTPS come HTTP. Spero che questo aiuti qualcuno in prima linea.

+0

mi ha aiutato 2 anni dopo! Grazie! – UrsulRosu

-2

Nel client app.config o web.config prima controllare l'URL del servizio Web, se l'URL del servizio Web dispone del certificato Secure Sockets Layer, quindi aggiungere lo stesso URL di abilitazione di Secure Sockets Layer a app.config o web.config. Ti piace questa "https://crm.XXXX.com/webServiceName.asmx"

System.Net.WebException: richiesta non riuscita con una risposta vuota

4

Vorrei aggiungere a quanto affermato Andacious. Stavo facendo una chiamata a un servizio web che era https ma quando ho guardato le proprietà dell'oggetto facendo la chiamata in realtà stava usando http. Così ho impostato in modo specifico la proprietà URL.

Ho una classe chiamata interscambio che eredita da SoapHttpClientProtocol.

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

string x = interchangeWS.SomeMethod("someParameter"); 
Problemi correlati