接口地址http://www.webxml.com.cn/WebServices/WeatherWebService.asmx调用步骤:项目添加服务引用-高级-添加web引用简单代码: ??web服务名.WeatherWebService w = new web服务名.WeatherWebService(); ???????????//把webservice当做一个类来操作 ?????????????string[] s = new string[23];//声明string数组存放返回结果 ?????????????string city = this.textBox1.Text.Trim();//获得文本框录入的查询城市 ?????????????s = w.getWeatherbyCityName(city); ???????????//以文本框内容为变量实现方法getWeatherbyCityName ?????????????if (s[8] == "") ???????????{ ???????????????MessageBox.Show("暂时不支持您查询的城市"); ???????????} ???????????else ???????????{ ???????????????this.GaiKuang.Text = s[1] + " " + s[6]; ???????????????richTextBox1.Text = s[10]; ???????????}
.Net 调用中国气象台Web Service
原文地址:https://www.cnblogs.com/iWaitYou/p/9434048.html