首页 > Web开发 > 详细

Web服务的调用

时间:2017-12-06 10:16:39      阅读:223      评论:0      收藏:0      [点我收藏+]

 

1.创建服务引用

例如:天气预报

 

2.在代码添加引用空间

技术分享图片
1   TvProgram.ChinaTVprogramWebService tp = new TvProgram.ChinaTVprogramWebService();
2         DataSet ds=    tp.getAreaDataSet();
View Code

 3.引用具体方法

 1  private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
 2         {
 3             ComboBox cb = (ComboBox)sender;
 4             if(comboBox1.SelectedIndex>0)
 5             { 
 6            
 7              int num= Convert.ToInt32(cb.SelectedValue.ToString());
 8 
 9              TvProgram.ChinaTVprogramWebService tp = new TvProgram.ChinaTVprogramWebService();
10              DataSet ds = tp.getTVstationDataSet(num);
11              comboBox2.DataSource = ds.Tables[0];
12              comboBox2.DisplayMember = "tvStationName";
13              comboBox2.ValueMember = "tvStationID";
14            
15             }
16         }

 

返回的xml用两种处理方法

  //DataRow[] dt = ds.Tables[0].Select();   
       //for (int i = 3; i < dt.Length; i++)
       //{
       //    Text = dt[i]["Area"].ToString();
       //   Value = Convert.ToInt32(dt[i]["areaID"].ToString());
        //    comboBox1.Items.Add(Text);
       //}
       
 comboBox1.DataSource = ds.Tables[0];
        comboBox1.DisplayMember = "Area";
        comboBox1.ValueMember = "areaID";

 

Web服务的调用

原文:http://www.cnblogs.com/yyl001/p/7991288.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!