.net转换webservice返回的dataset

string paras = "loginName=admin";//参数
            byte[] bytes = Encoding.UTF8.GetBytes(paras);

            HttpWebRequest httpRequest = (HttpWebRequest)WebRequest.Create("http://localhost:6666/WebService1.asmx/GetPerson");
            //HttpWebRequest httpRequest = (HttpWebRequest)WebRequest.Create("http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx/getRegionDataset");
            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);
                }
            }

 

.net转换webservice返回的dataset,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。