我們正在使用網站的Web服務與外部服務器進行通信。 外部服務器請求會話ID。HttpWebRequest:如何獲取會話ID
我們下面的代碼向外部服務器:
HttpWebRequest webRequest = WebRequest.Create(ExtUrl) as HttpWebRequest;
webRequest.Credentials = new NetworkCredential(ExtAccountToUse, ExtPassword);
HttpWebResponse webResponse;
webRequest.Method = "POST";
webRequest.ContentType = "application/x-www-form-urlencoded";
StreamWriter writer = new StreamWriter(webRequest.GetRequestStream());
writer.Write(xmlOutput);
writer.Close();
webResponse = webRequest.GetResponse() as HttpWebResponse;
是否有可能得到一個會話ID發送到外部服務器?
感謝您的時間
您似乎在發送XML(xmlOutput),但您將內容類型設置爲標準HTML表單文章,這有點奇怪,爲什麼不使用「text/xml」作爲內容類型? – AnthonyWJones 2009-08-25 09:52:28
外部服務器以什麼方式「請求會話ID」。 – AnthonyWJones 2009-08-25 09:53:21
外部服務器在發送給服務器的第一個請求上是否要求會話ID?因爲應該由目標服務器負責生成一個有效的會話標識,然後可以在客戶端中重新使用它。 – 2009-08-25 09:56:12