I am having an issue in calling specific WS's when the response takes longer than 100 seconds to be generated.
Following my code:
try {
XmlDocument soapEnvelopeXml = CreateSoapEnvelope(request);
HttpWebRequest webRequest = CreateWebRequest(url, action, username, password);
webRequest.ContinueTimeout = 200000;
webRequest.ReadWriteTimeout = 200000;
InsertSoapEnvelopeIntoWebRequest(soapEnvelopeXml, webRequest);
// begin async call to web request.
IAsyncResult asyncResult = webRequest.BeginGetResponse(null, null);
// suspend this thread until call is complete. You might want to
if( asyncResult.AsyncWaitHandle.WaitOne(-1) )
{
//MessageBox.Show("Call completed!!!");
// get the response from the completed web request.
string soapResult;
using (WebResponse webResponse = webRequest.EndGetResponse(asyncResult))
{
using (StreamReader rd = new StreamReader(webResponse.GetResponseStream()))
{
soapResult = rd.ReadToEnd();
}
response = soapResult;
success = true;
errMessage = "";
}
}
else
{
MessageBox.Show( "Call didn't complete in 180 seconds" );
errMessage = "Call didn't complete in 180 seconds";
throw new Exception(errMessage);
}
}
catch(Exception ex) {
errMessage = ex.GetType().Name + " " + ex.Message;
success = false;
response = "";
}
I tried several suggested ways to set a proper timeout, but unfortunately no success. Can you please help me in solving this issue?