HttpWebRequest req;
string strGet = "http://localhost:2980/Service1.asmx/HelloWorld?name=";
strGet = strGet + this.TextBox1.Text; //请求的Web service的所在地址
req = (HttpWebRequest)WebRequest.Create(strGet); //依据地址创建一个请求对象
HttpWebResponse response;
response = (HttpWebResponse)req.GetResponse(); //根据请求得到响应
Stream s = response.GetResponseStream(); //得到响应流
XmlTextReader reader = new XmlTextReader(s); //读出流中的XML内容
reader.MoveToContent(); //跳过第一行<?xml version="1.0" encoding="utf-8">
Label2.Text = reader.ReadInnerXml(); //将XML的内容赋给lable3
reader.Close(); //关闭流