您的位置:首页 > 其它

.Net 调用中国气象台Web Service

2018-08-06 22:49 246 查看
接口地址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];
}


  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: