天气web service 接口地址:http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx
代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Weather.WeatherWebServiceSoapClient w = new Weather.WeatherWebServiceSoapClient("WeatherWebServiceSoap");
string[] s = new string[32];
s = w.getWeatherbyCityName(textBox1.Text);
if (s[8] == "")
{
MessageBox.Show("暂时不支持您查询的城市");
}
else
{
richTextBox1.Text="";
for (int i = 0; i <= 22; i++)
{
richTextBox1.Text += s[i];
}
}
}
}
}