• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
真老K
博客园    首页    新随笔    联系   管理    订阅  订阅

查询天气的服务引用,有类似的吧;

首先要引用这个服务,http://www.webxml.com.cn/Webservices/WeatherWebService.asmx

添加服务和引用---->转到---->高级---->添加WEB应用---->添加引用       到此OK。                           1个text,1个button,2个lable

private void btn_search_Click(object sender, EventArgs e)
{
cn.com.webxml.www.WeatherWebService w = new cn.com.webxml.www.WeatherWebService();
string[] s = new string[23];
string city = text_city.Text.Trim();
s = w.getWeatherbyCityName(city);
if(s[8]=="")
{
MessageBox.Show("暂不支持查询的城市");
}
else
{
label_gaikuang.Text = s[1] + "" + s[6];
label_shikuang.Text = s[10];
MessageBox.Show(s[3]+"\n\r"+s[4]+s[5]+s[7]+s[8]+s[9]);
}
}

 w.getWeatherbyCityName(city);    返回的是一个以为数组,有兴趣的话可以看看里面都是什么内容;

posted @ 2019-07-18 19:42  真老K  阅读(300)  评论(3)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3