Last post Jul 27, 2011 01:27 AM by Mamba Dai - MSFT
Jul 21, 2011 12:47 PM|ashuagarwal|LINK
I am calling a webservice from my application. I am passing a xml and the webservice returns back an xml. this works for 90% of the time, but for 10%, if the xml that I am passing is big, then I get a message that
System.Net.WebException: The operation has timed out at System.Net.HttpWebRequest.GetResponse()
I have been working on this issue for quite some time now and have tried many solutions listed on the web, but nothing seems to be working for me.
can anyone please help me. I would greatly appreciate your help. my code is:
string CsiUrl = ConfigurationSettings.AppSettings["CsiUrl"];
WebRequest req = WebRequest.Create(CsiUrl);
XmlDocument unratedXml = GetXml(QuoteId);
// req.ContentType = "application/xml";
req.ContentType = "text/xml";
req.Method = "POST";
StreamWriter writer = new StreamWriter(req.GetRequestStream());
Logger.Instance.LogMessage("Call to Rating WebService started", Convert.ToInt32(SessionHandler.QuoteId), "GetRates()", "BOPPriceIndication.cs");
req.Timeout = 1000000000;
using (WebResponse res = req.GetResponse())
Stream s = res.GetResponseStream();
xmlString = new StreamReader(s).ReadToEnd();
in the web.config, i have the following entries:
<add address="*" maxconnection="2" />
<httpRuntime executionTimeout="480000" maxRequestLength="2097151"/>
Jul 21, 2011 01:05 PM|vijayst|LINK
Can you try using async operations? What is the timespan after which the request times out?
Jul 21, 2011 01:15 PM|ashuagarwal|LINK
thanks for your reply.
the request times out after about 1 minute. the strange thing is that when I call the test web-service url, then everything works fine, but it gives an error when calling the production url.
can you please tell me how to call this using "async operations". thanks.
Jul 21, 2011 01:27 PM|alstephen|LINK
maybe this can help you:
Jul 22, 2011 10:37 AM|ashuagarwal|LINK
I tried everything that is mentioned, but am still getting the same error when passing the bigger xmls.
Jul 27, 2011 01:27 AM|Mamba Dai - MSFT|LINK
Please try WebClientProtocol.Timeout Property which indicates the time an XML Web Service client waits for the reply to a synchronous XML Web Service request to arrive.
More information please check this link:
This post discuss a similar topic with yours you may have a check；