L
Lee Wilson
The concept is to display the current user's inbox (located on a remote
Exchange 2003 server) from the intranet home page. The following code has
been written:
string studentLoginId = "LOGINID";
string studentPassword = "PASSWORD";
string studentInbox = string.Format("{0}{1}/{2}/",
Properties.Settings.Default.StudentExchangeLoc, studentLoginId,
Properties.Settings.Default.InboxFolder);
string inboxQuery = "<?xml version=\"1.0\"?>"
+ "<D:searchrequest xmlns = \"DAV:\"><D:sql>"
+ "SELECT \"urn:schemas:httpmail:datereceived\""
+ ",\"urn:schemas:httpmail:normalizedsubject\""
+ ",\"urn:schemas:httpmail:importance\""
+ ",\"urn:schemas:httpmail:read\""
+ " FROM scope('shallow traversal of \"" + studentInbox
+ "\"')"
+ " WHERE \"DAV:ishidden\" = " + false
+ " AND \"DAV:isfolder\" = " + false
+ "</D:sql></D:searchrequest>";
byte[] bytes = System.Text.Encoding.UTF8.GetBytes(String.Format(inboxQuery,
studentInbox));
HttpWebRequest request =
(HttpWebRequest)HttpWebRequest.Create(studentInbox);
request.Method = "SEARCH";
request.ContentLength = bytes.Length;
request.ContentType = "text/xml";
request.Credentials = new NetworkCredential(studentLoginId,
studentPassword);
using (System.IO.Stream requestStream = request.GetRequestStream())
{
requestStream.Write(bytes, 0, bytes.Length);
requestStream.Close();
}
WebResponse response = (HttpWebResponse)request.GetResponse();
System.IO.StreamReader reader = new
System.IO.StreamReader(response.GetResponseStream());
string xml = reader.ReadToEnd();
System.Xml.XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(xml);
When this is run locally on my development machine, everything works fine.
Once deployed to the intranet there is an exception: (502 Bad Gateway). The
exception occurs when the GetRequestStream() method is called. For testing
purposes, the web application was deployed to the Exchange server, and it
worked as intended.
Any clues would be fantastic,
Lee Wilson
Exchange 2003 server) from the intranet home page. The following code has
been written:
string studentLoginId = "LOGINID";
string studentPassword = "PASSWORD";
string studentInbox = string.Format("{0}{1}/{2}/",
Properties.Settings.Default.StudentExchangeLoc, studentLoginId,
Properties.Settings.Default.InboxFolder);
string inboxQuery = "<?xml version=\"1.0\"?>"
+ "<D:searchrequest xmlns = \"DAV:\"><D:sql>"
+ "SELECT \"urn:schemas:httpmail:datereceived\""
+ ",\"urn:schemas:httpmail:normalizedsubject\""
+ ",\"urn:schemas:httpmail:importance\""
+ ",\"urn:schemas:httpmail:read\""
+ " FROM scope('shallow traversal of \"" + studentInbox
+ "\"')"
+ " WHERE \"DAV:ishidden\" = " + false
+ " AND \"DAV:isfolder\" = " + false
+ "</D:sql></D:searchrequest>";
byte[] bytes = System.Text.Encoding.UTF8.GetBytes(String.Format(inboxQuery,
studentInbox));
HttpWebRequest request =
(HttpWebRequest)HttpWebRequest.Create(studentInbox);
request.Method = "SEARCH";
request.ContentLength = bytes.Length;
request.ContentType = "text/xml";
request.Credentials = new NetworkCredential(studentLoginId,
studentPassword);
using (System.IO.Stream requestStream = request.GetRequestStream())
{
requestStream.Write(bytes, 0, bytes.Length);
requestStream.Close();
}
WebResponse response = (HttpWebResponse)request.GetResponse();
System.IO.StreamReader reader = new
System.IO.StreamReader(response.GetResponseStream());
string xml = reader.ReadToEnd();
System.Xml.XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(xml);
When this is run locally on my development machine, everything works fine.
Once deployed to the intranet there is an exception: (502 Bad Gateway). The
exception occurs when the GetRequestStream() method is called. For testing
purposes, the web application was deployed to the Exchange server, and it
worked as intended.
Any clues would be fantastic,
Lee Wilson