baavgai: (tech)
([personal profile] baavgai Nov. 20th, 2007 11:37 am)
Only a programmer would care. The following two bits should be functionally identical. Except that only one works. I post so I'll remember.

I got to the point where I pack sniffed the HTTP transactions.


Doesn't Work:
private HttpWebRequest PrepRequest(XmlDocument xmlDoc) {
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(this.ServiceUrl);
req.Method = "POST";
req.ContentType = "text/xml";
using (XmlTextWriter writer = new XmlTextWriter(req.GetRequestStream(), Encoding.ASCII)) {
xmlDoc.WriteTo(writer);
}
req.CookieContainer = new CookieContainer();
if (this.cookies != null) {
req.CookieContainer.Add(this.cookies);
}
return req;
}


Works:
private HttpWebRequest PrepRequest(XmlDocument xmlDoc) {
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(this.ServiceUrl);
req.Method = "POST";
req.ContentType = "text/xml";
req.CookieContainer = new CookieContainer();
if (this.cookies != null) {
req.CookieContainer.Add(this.cookies);
}
using (XmlTextWriter writer = new XmlTextWriter(req.GetRequestStream(), Encoding.ASCII)) {
xmlDoc.WriteTo(writer);
}
return req;
}


If, by any chance, someone does follow this code. Yes, I did spend the morning loosing my cookies. :p
.

Profile

baavgai: (Default)
baavgai

Links

Most Popular Tags

Powered by Dreamwidth Studios

Style Credit

Expand Cut Tags

No cut tags