添加个项目,把这个web service添加到项目中,生成了代理之后调用方法即可再说这些方法也注释齐全
解决方案 »
- 委托执行的方法是不是相当于建立了一个后台子线程
- c# 怎样获取文本框textbox的光标位置
- access权限问题
- listbox字符长度,格式化后长段不一。。100分
- 求助,关于DataGrid的一个初级问题,谢谢
- 我没有调wati()、sleep()和join()为什么线程状态还会被改为WaitSleepJoin?
- ajax的问题,路过的看看!
- 关于mdi窗体问题????
- 如何将 .NET 程序迁移到 Crystal Report 9.2……(更新:2003-10-12,作者:海波.NET)
- 急,求解
- 使用System.DirectoryServices.DirectoryEntry操作远程IIS时的问题
- winform 动态生成控件,取值和赋值问题。
代码写的很清楚
然后调用
WebXml.ChinaTVprogramWebService tv = new WebXml.ChinaTVprogramWebService();tv.getTVprogramDateSet(theTVchannelID, theDate, userID);
cn.com.webxml.www.WeatherWebService ws = new cn.com.webxml.www.WeatherWebService();
string[] items = ws.getWeatherbyCityName("重庆");
for (int i = 0; i < items.Length; i++)
{
Response.Write(i + "、" + items[i] + "<br>");
}就这么简单,返回的结果是以数组的形式保存的,我们这里把这个数组的内容输出出来,便于我们查看每一项保存的是什么内容,以便决定使用哪一项。
免费的啊!!不需要钱的!! string[] strArrs = new string[23];
Weather.WeatherWebServiceSoapClient w = new Weather.WeatherWebServiceSoapClient("WeatherWebServiceSoap");
strArrs = w.getWeatherbyCityName("惠州");
if (strArrs[8] == "")
{
this.lblTest.Text = "无法获取天气情况";
}
else
{
this.lblTest.Text = strArrs[1] + " " + strArrs[6];
this.img1.ImageUrl = @"~/Pic/" + strArrs[8];
}这个网站会提供一系列相关的天气显示图片,你先拷贝到项目中!
{
weathertest2.Weather.WeatherWebServiceSoapClient w = new weathertest2.Weather.WeatherWebServiceSoapClient("WeatherWebServiceSoap");
//把webservice当做一个类来操作
string[] s = new string[23];//声明一个string数组存放其返回的结果
string c = this.textBox15.Text.Trim();
s = w.getWeatherbyCityName(c);
textBox1.Text = s[0];
textBox2.Text = s[1];
textBox3.Text = s[2];
textBox4.Text = s[4];
textBox5.Text = s[5];
textBox6.Text = s[6];
textBox7.Text = s[7];
textBox8.Text = s[10];
textBox9.Text = s[12];
textBox10.Text = s[13];
textBox11.Text = s[14];
textBox12.Text = s[17];
textBox13.Text = s[18];
textBox14.Text = s[19];
}
//创建ASP.NET Web服务
//默认生成一个Web Service服务代码
//在解决方案添加Web引用
//在弹出的对话框中输入天气预报飞服务器地址
//引用命名空间
using System .Web .Services ;
using obj; //引用
//在网页中实例化
obj.Service myobj = new obj.Service(); //实例化
//加载调用自定义方法
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
BindPro();
BindCity();
BindWeather();
}
}
// 获得省份
protected void BindPro()
{
string [] pro=myobj.getSupportProvince();
for (int i = 1; i <= Int32 .Parse (pro[0]); i++)
{
DropDownList1.Items.Add(new ListItem (pro[i].ToString (),pro[i].ToString()));
}
}
//获得城市
protected void BindCity()
{
DropDownList2.Items.Clear();
string[] city = myobj.getSupportCity (DropDownList1 .SelectedValue );
for (int i = 1; i <= Int32.Parse(city[0]); i++)
{
DropDownList2.Items.Add(new ListItem(city[i].ToString(), city[i].ToString()));
}
}
//天气预报
protected void BindWeather()
{
string[] mystr = myobj.getWeatherbyCityName(DropDownList2 .SelectedValue , theDayFlagEnum.Today);
Label1.Text = mystr[1].ToString();
Label2.Text = mystr[2].ToString();
Label3.Text = mystr[3].ToString();
Label4.Text = mystr[4].ToString();
Label5.Text = mystr[5].ToString();
Image1.ImageUrl = mystr[6].ToString();
}