[App] 讀取xml檔改成 讀取線上的N4資料

This commit is contained in:
wanli 2022-12-22 10:13:53 +08:00
parent f9e803ef88
commit 0e0858d4bd

View File

@ -149,24 +149,24 @@ namespace tpDomeWinAPP.Service
String encoded = System.Convert.ToBase64String(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(username + ":" + password));
String API_Url = urlString;
//HttpWebRequest Postrequest = (HttpWebRequest)WebRequest.Create(API_Url);
//Postrequest.Method = "POST";
//Postrequest.Headers.Add("Authorization", "Basic " + encoded);
//Postrequest.PreAuthenticate = true;
HttpWebRequest Postrequest = (HttpWebRequest)WebRequest.Create(API_Url);
Postrequest.Method = "POST";
Postrequest.Headers.Add("Authorization", "Basic " + encoded);
Postrequest.PreAuthenticate = true;
//using (var streamWriter = new StreamWriter(Postrequest.GetRequestStream()))
//{
// string json = "<str val='" + bql + "'/>";
using (var streamWriter = new StreamWriter(Postrequest.GetRequestStream()))
{
string json = "<str val='" + bql + "'/>";
// streamWriter.Write(json);
//}
streamWriter.Write(json);
}
//HttpWebResponse response = (HttpWebResponse)Postrequest.GetResponse();
//var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
HttpWebResponse response = (HttpWebResponse)Postrequest.GetResponse();
var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
XmlDocument xmlDoc = new XmlDocument();
//xmlDoc.LoadXml(responseString);
xmlDoc.Load("N4v1021.xml");//N4v1021
xmlDoc.LoadXml(responseString);
//xmlDoc.Load("N4v1021.xml");//N4v1021
//xmlDoc.Save("N4.xml");