.Net 调用中国气象台Web Service

本文介绍如何通过WebXML服务接口调用获取天气预报,并提供了详细代码示例,包括服务引用、方法调用及错误处理。
接口地址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];
            }

  

转载于:https://www.cnblogs.com/ZaraNet/p/9434048.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值