首页 > Web开发 > 详细

.net转换webservice返回的dataset

时间:2014-08-14 20:07:09      阅读:383      评论:0      收藏:0      [点我收藏+]
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,布布扣,bubuko.com

.net转换webservice返回的dataset

原文:http://www.cnblogs.com/cuinian/p/3913132.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!