E
Edwardraoul
I need to send multiple WebRequests in the same session. The problem is I send the first request, which is a login request, receive the reply that the login is successful, then attempt to send another request, but receive a message back that I am not logged in. All of the requests are XML documents as well as the replies. Here is the code I have so far, which doesn't work..
string proxy = null;
XmlDocument LoginXml = login; //login xml documen
XmlDocument query = new XmlDocument(); //next transactio
query.Load("test.xml")
HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://url"
if(proxy != null) req.Proxy = new WebProxy(proxy,true)
req.ContentType = "text/xml";//;charset=\"utf-8\""
req.Accept = "text/xml"
req.Method = "POST"
Stream stm = req.GetRequestStream(); //sends first request to serve
LoginXml.Save(stm)
stm.Close()
WebResponse resp = req.GetResponse(); recieves response and stores in st
stm = resp.GetResponseStream()
Stream stm2 = req.GetRequestStream(); //attempt to send second reques
query.Save(stm2)
stm2.Close(); //this results in an error (stream not writable
StreamReader r = new StreamReader(stm)
string response = r.ReadToEnd(); //reads received stream into strin
r.Close(); //close streamreade
return response
I have tried many different methods to no avail, any advice would be greatly appreciated
Thank you
edward
string proxy = null;
XmlDocument LoginXml = login; //login xml documen
XmlDocument query = new XmlDocument(); //next transactio
query.Load("test.xml")
HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://url"
if(proxy != null) req.Proxy = new WebProxy(proxy,true)
req.ContentType = "text/xml";//;charset=\"utf-8\""
req.Accept = "text/xml"
req.Method = "POST"
Stream stm = req.GetRequestStream(); //sends first request to serve
LoginXml.Save(stm)
stm.Close()
WebResponse resp = req.GetResponse(); recieves response and stores in st
stm = resp.GetResponseStream()
Stream stm2 = req.GetRequestStream(); //attempt to send second reques
query.Save(stm2)
stm2.Close(); //this results in an error (stream not writable
StreamReader r = new StreamReader(stm)
string response = r.ReadToEnd(); //reads received stream into strin
r.Close(); //close streamreade
return response
I have tried many different methods to no avail, any advice would be greatly appreciated
Thank you
edward