dotnet转换webservice返回的dataset

·  阅读 111
 byte[] bytes = Encoding.UTF8.GetBytes(paras);
 HttpWebRequest httpRequest = (HttpWebRequest)WebRequest.Create("http://localhost:8080/WebService1.asmx/Test");
 httpRequest.UserAgent = "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT6.2; WOW64; Trident/6.0; Touch; ASU2JS)";
 httpRequest.ContentLength = bytes.Length;
 httpRequest.ContentType = "application/x-www-form-urlencoded";
 httpRequest.Method = "POST";
 using (Stream sm = httpRequest.GetRequestStream())
 {
     sm.Write(bytes, 0, bytes.Length);
 }
 HttpWebResponse respone = httpRequest.GetResponse() as HttpWebResponse;
 using (Stream sr = respone.GetResponseStream())
 {
     using (StreamReader sr2 = new StreamReader(sr, Encoding.GetEncoding("UTF-8")))
     {
         string xml = sr2.ReadToEnd();
         StringReader stream = null;
         XmlTextReader reader = null;
         DataSet xmlDS = new DataSet();
         stream = new StringReader(xml);
         //从stream装载到XmlTextReader
         reader = new XmlTextReader(stream);
         xmlDS.ReadXml(reader);
     }
 }
复制代码
分类:
后端
标签:
分类:
后端
标签:
收藏成功!
已添加到「」, 点击更改