Request has timed

L

laks

Hi all

I have the following piece of code for retrieving some info from an
external url. I receive an error - "The operation has timed-out" at
GetResponse() line. I have tried extending the time out duration. I
dont have any SETI etc on my computer. Anything wrong in code? how can
i resolve my issue?

Any insight highly appreciated..
thanks
laks..
------------------------------------------
strXmlRequest = "Something in xml";

XmlDocument xmlDoc;
xmlDoc = new XmlDocument();
xmlDoc.LoadXml(strXmlRequest);

// Create an HTTP request to do a POST
System.Net.HttpWebRequest xmlHttpRequest = (HttpWebRequest)
WebRequest.Create("http://www.somesite.com/ExtInterface/ListingSearch.asp");
xmlHttpRequest.Method="POST";

// Write the serialized XML to the request.
XmlTextWriter xmlWriter = new
XmlTextWriter(xmlHttpRequest.GetRequestStream(),
Encoding.GetEncoding("UTF-8"));
xmlDoc.WriteTo(xmlWriter);

// Force the XML text writer to finish
xmlWriter.Flush();

// Get the response from the server
System.Net.HttpWebResponse xmlHttpResponse = (HttpWebResponse)


xmlHttpRequest.GetResponse();

// Parse the response into a new XmlDocument and return it.
XmlDocument respDoc = new XmlDocument();
respDoc.Load(xmlHttpResponse.GetResponseStream());
xmlHttpResponse.Close();
------------------------------------------------
 
S

Steve Lutz

Have you verified that the external site you are going to actually returns a
page?

I would first simplify the code:

1) Create Request
2) Open
3) Response.Write(result)

You can through come try/catches also in there around the Get, then walk
through the code in debug so you can look closer at the Exceptions that are
thrown.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top