日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程语言 > C# >内容正文

C#

C#调用webservice(二)

發(fā)布時間:2024/1/17 C# 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 C#调用webservice(二) 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

第二篇調(diào)用webservice,web服務(wù)是http://webservice.webxml.com.cn/webservices/DomesticAirline.asmx,航班查詢服務(wù)

添加web服務(wù)的方法是:在visual studio中的“解決方案管理器”的項目中有個“引用”,右擊“添加服務(wù)引用”,在對話框中輸入webservice的URL,點擊“前往”,再“確定”就好了。

此服務(wù)有兩個方法:?getDomesticAirlinesTime(string,string,string,string) ? ?//四個參數(shù),返回DataSet
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?getDomesticCity() ? ?//無參數(shù),返回DataSet
?
1.用了兩個listview來顯示結(jié)果
listview的使用:添加列標(biāo)題

1 listView1.View = View.Details; 2 listView1.Columns.Add("航空公司", -2, HorizontalAlignment.Left); 3 listView1.Columns.Add("航班號", -2, HorizontalAlignment.Left);

2.要用的命名空間:

1 using System.Net; 2 using System.Data;

3.添加控件:

1 private void button3_Click(object sender, EventArgs e) 2 { 3 ServiceReference2.DomesticAirlineSoapClient ww = new ServiceReference2.DomesticAirlineSoapClient("DomesticAirlineSoap"); 4 DataSet s = new DataSet(); 5 s = ww.getDomesticAirlinesTime(textBox2.Text,textBox3.Text,textBox4.Text,string.Empty); 6 int RowCount = s.Tables[0].Rows.Count; 7 int ColumnCount = s.Tables[0].Columns.Count; 8 for (int i = 0; i < RowCount; i++) 9 { 10 string itemName = s.Tables[0].Rows[i][0].ToString(); 11 ListViewItem item = new ListViewItem(itemName, i); 12 //循環(huán)每一列 13 for (int j = 1; j < ColumnCount; j++) 14 { 15 item.SubItems.Add(s.Tables[0].Rows[i][j].ToString()); 16 } 17 listView1.Items.Add(item); 18 } 19 } 20 private void button4_Click(object sender, EventArgs e) 21 { 22 ServiceReference2.DomesticAirlineSoapClient ww = new ServiceReference2.DomesticAirlineSoapClient("DomesticAirlineSoap"); 23 DataSet s = new DataSet(); 24 s = ww.getDomesticCity(); 25 int RowCount = s.Tables[0].Rows.Count; 26 int ColumnCount = s.Tables[0].Columns.Count; 27 for (int i = 0; i < RowCount; i++) 28 { 29 string itemName = s.Tables[0].Rows[i][0].ToString(); 30 ListViewItem item = new ListViewItem(itemName, i); 31 //循環(huán)每一列 32 for (int j = 1; j < ColumnCount; j++) 33 { 34 item.SubItems.Add(s.Tables[0].Rows[i][j].ToString()); 35 } 36 listView2.Items.Add(item); 37 } 38 }

4.最后結(jié)果:(和上一次的弄一起了)

?

轉(zhuǎn)載于:https://www.cnblogs.com/cjxy1993/p/4118306.html

總結(jié)

以上是生活随笔為你收集整理的C#调用webservice(二)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。