110,538
社区成员
发帖
与我相关
我的任务
分享
string strURL = "http://192.168.140.2:8899/WebService.asmx/getCardsStatus?cellphone=";
strURL += this.textBox1.Text;
//创建一个HTTP请求
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(strURL);
request.Method="get";
HttpWebResponse response = (System.Net.HttpWebResponse)request.GetResponse();
Stream s = response.GetResponseStream();
//转化为XML,自己进行处理
XmlTextReader Reader = new XmlTextReader(s);
Reader.MoveToContent();
string strValue = Reader.ReadInnerXml();
strValue = strValue.Replace("<", "<");
strValue = strValue.Replace(">", ">");
MessageBox.Show(strValue);
Reader.Close();
var xxoo=new webservice().xxoo(参数);
正常来说xxoo就是一个符合json规范的string
比如{"cellphone": "111", "status": "ture"} 你通过反序列化 可以拿到里面的值..
如果你不想添加引用的话..你直接请求接口地址(接口要支持httpget才行).
那么你请求接口返回值是很长的字符串 但是实际上 里面是包含命名空间的 xml
然后在去解析找到对应的值..
所以我觉得还是LZ看看 "如何添加引用"吧
根本不是写服务的人没告诉你清楚,是你了解的太少了..........
localhost.WebService obj = new localhost.WebService();
private void button1_Click(object sender, EventArgs e)
{
string cc = obj.getCardsStatus(textBox1.Text);
MessageBox.Show(cc);
}