I am reusing the following code to make webdav requests to a microsoft
exchange server:
/
****************************************************************************************************/
public XmlDocument getXmlData(string requestMethod, string
webDavQuery)
{
System.Xml.XmlDocument responseXmlDoc;
System.Net.HttpWebRequest request = null;System.Net.WebResponse
response = null;
byte[] bytes = null;
System.IO.Stream requestStream;
// Create the HttpWebRequest object.
request = (System.Net.HttpWebRequest)HttpWebRequest.Create
(strCalendarURI);
// Add the network credentials to the request.
request.Credentials = this.credentials;
// Specify the method.
request.Method = requestMethod;
// Encode the body using UTF-8.
bytes = Encoding.UTF8.GetBytes((string)webDavQuery);
// Set the content header length. This must be
// done before writing data to the request stream.
request.ContentLength = bytes.Length;
// Get a reference to the request stream.
requestStream = request.GetRequestStream();
// Write the SQL query to the request stream.
requestStream.Write(bytes, 0, bytes.Length);
// Set the content type header.
request.ContentType = "text/xml";
// Send the SEARCH method request and get the
// response from the server.
response = (HttpWebResponse)request.GetResponse();
// Get the XML response stream.
requestStream.Close();
requestStream.Flush();
System.IO.Stream responseStream = response.GetResponseStream();
// Create the XmlDocument object from the XML response stream.
responseXmlDoc = new XmlDocument();
responseXmlDoc.Load(responseStream);
responseStream.Close();
responseStream.Flush();
response.Close();
return responseXmlDoc;
}
/
*********************************************************************************/
When two sequential requests are made in less than 2 minutes,
regardless of the type of requests that they are, the first request is
served successfully, but the second request always returns a bad
request error (400) like the following, .
The remote server returned an error: (400) Bad Request.
Line 65: // Send the SEARCH method request and get the
Line 66: // response from the server.
Line 67: response = (HttpWebResponse)request.GetResponse();
Line 69: // Get the XML response stream.
This problem does not occur if more than 2 minutes pass between
requests.
I was wondering if anyone else has had a similar problem and how they
have recovered from it.