This is really kicking my butt.
It appears that the server is not getting my data that I am posting...
Basically I am posting a little XML and getting back a response as to
whether it was accepted or not.
I am getting:
System.Xml.XmlException
Root element is missing.
at System.Xml.XmlTextReaderImpl.Throw(Exception e) at
....
private void SubmitWebRequest(string aDomain, string aURL)
{
string PostData = "<?xml version='1.0' ?
><orderstatus>Shipped</orderstatus>";ASCIIEncoding encoding = new ASCIIEncoding();
System.Net.CookieContainer CookieC = new
System.Net.CookieContainer();
Byte[] Data = encoding.GetBytes(PostData);
System.Net.HttpWebRequest LoginReq =
(System.Net.HttpWebRequest)System.Net.WebRequest.C reate(aDomain+aURL);
LoginReq.KeepAlive = false;
LoginReq.Method = "POST";
LoginReq.AllowAutoRedirect = false;
LoginReq.ContentType = "application/x-www-form-
urlencoded";
LoginReq.ContentLength = Data.Length;
LoginReq.CookieContainer = CookieC;
System.IO.Stream SendReq = LoginReq.GetRequestStream();
SendReq.Write(Data, 0, Data.Length);
SendReq.Close();
System.Net.HttpWebResponse LoginRes =
(System.Net.HttpWebResponse)LoginReq.GetResponse() ;
string sRedirect = LoginRes.Headers.Get("Location");
CookieC.Add(LoginRes.Cookies);
LoginReq =
(System.Net.HttpWebRequest)System.Net.WebRequest.C reate(aDomain
+sRedirect);
LoginReq.KeepAlive = false;
LoginReq.Method = "GET";
LoginReq.ContentType = "application/x-www-form-
urlencoded";
LoginReq.AllowAutoRedirect = true;
LoginReq.CookieContainer = CookieC;
LoginRes =
(System.Net.HttpWebResponse)LoginReq.GetResponse() ;
StreamReader sReader = new
StreamReader(LoginRes.GetResponseStream());
string HTML = sReader.ReadToEnd();
System.Windows.Forms.MessageBox.Show(HTML);
}
Any help would be MUCH appreciated!
GINA_M