基本信息
源码名称:WebService接口实现天气预报
源码大小:5.92M
文件格式:.zip
开发语言:C#
更新时间:2014-04-15
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300

本次赞助数额为: 4 元 
   源码介绍

调用公共WebService接口实现天气预报。 最后更新与 2018年4月,附件分为两个版本,现新增了 新版的webservice调用方法,如下




using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WeatherWEBService
    {
    public partial class Form1 : Form
        {
        public Form1()
            {
            InitializeComponent();
            }

        private void button1_Click(object sender, EventArgs e)
            {
            cn.com.webxml.www.WeatherWebService w = new cn.com.webxml.www.WeatherWebService();
            //Weather.WeatherWebServiceSoapClient w = new Weather.WeatherWebServiceSoapClient("WeatherWebServiceSoap");
            ////把webservice当做一个类来操作  
            string[] s = new string[23];//声明string数组存放返回结果  
            string city = this.textBox1.Text.Trim();//获得文本框录入的查询城市  
            try
                {
                s = w.getWeatherbyCityName(city);
                //以文本框内容为变量实现方法getWeatherbyCityName  
                if (s[8] == "")
                    {
                    MessageBox.Show("暂时不支持您查询的城市!","提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                else
                    {
                    pictureBox1.Image = Image.FromFile(Application.StartupPath   @"/weatherpic/"   s[8]   "");
                    pictureBox2.Image = Image.FromFile(Application.StartupPath   @"/weatherpic/"   s[9]   "");
                    this.label3.Text = s[1]   " "   s[6]   " "   s[7]   " "   s[5];
                    label7.Text = s[4];
                    textBox2.Text = s[10];
                    textBox3.Text = s[11];
                    //明天天气预报
                    label9.Text = s[1]   " "   s[13]   " "   s[14]   " "   s[12];
                    pictureBox3.Image = Image.FromFile(Application.StartupPath   @"/weatherpic/"   s[15]   "");
                    pictureBox4.Image = Image.FromFile(Application.StartupPath   @"/weatherpic/"   s[16]   "");
                    //后天天气预报
                    label10.Text = s[1]   " "   s[18]   " "   s[19]   " "   s[17];
                    pictureBox5.Image = Image.FromFile(Application.StartupPath   @"/weatherpic/"   s[20]   "");
                    pictureBox6.Image = Image.FromFile(Application.StartupPath   @"/weatherpic/"   s[21]   "");
                    richTextBox1.Text = s[22];
                    }  
                }
            catch (Exception ex)
                {
                MessageBox.Show("网络错误,请重试!","提示",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
                }
            }

        private void button2_Click(object sender, EventArgs e)
            {  
            this.Close();
            }
        }
    }