Click to See Complete Forum and Search --> : Not Solving "System.Net.WebException: The underlying connection was closed"


waaa768
May 22nd, 2005, 07:28 PM
Hi all,
I am coding a web service for the company I am working for. It supposes to talk to a third-party web service, via WSDL. The web reference which I am using is:
http://xml.nig.ac.jp/wsdl/SRS.wsdl

My code to test the web service is the following: (VS.net2003 C#)
private string QuerySRS(string queryString)
{

SRS search = new SRS();

string query = "[swissprotrelease-AllText:"+queryString+"]";
string param = "-f ID";

try
{
string results = search.searchSimple(query);
……………………………
}
catch
{
}
}

Trying to run this class, I got the error in below:

System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a receive. at System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest request) at System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse(WebRequest request) at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) at EBIResearch.jp.ac.nig.xml.SRS.searchSimple(String query)

And,
string results = search.searchSimple(query).ToString();

is the line causing the problem, which means I got no response back from the remove web service.

I have tried to add the following function in the Reference.cs, but still got the same problem.

protected override System.Net.WebRequest GetWebRequest(Uri uri)
{
System.Net.HttpWebRequest webRequest =
(System.Net.HttpWebRequest) base.GetWebRequest(uri);
webRequest.KeepAlive = false;
return webRequest;
}

I knew this is a common asked question, but any suggestions are welcome.

Thanks
Rui