C#调用webservice(二)
第二篇调用webservice,web服务是http://webservice.webxml.com.cn/webservices/DomesticAirline.asmx,航班查询服务
添加web服务的方法是:在visual studio中的“解决方案管理器”的项目中有个“引用”,右击“添加服务引用”,在对话框中输入webservice的URL,点击“前往”,再“确定”就好了。
此服务有两个方法: getDomesticAirlinesTime(string,string,string,string) //四个参数,返回DataSet
getDomesticCity() //无参数,返回DataSet
1.用了两个listview来显示结果
listview的使用:添加列标题
listView1.View = View.Details;
listView1.Columns.Add("航空公司", -, HorizontalAlignment.Left);
listView1.Columns.Add("航班号", -, HorizontalAlignment.Left);
2.要用的命名空间:
using System.Net;
using System.Data;
3.添加控件:
private void button3_Click(object sender, EventArgs e)
{
ServiceReference2.DomesticAirlineSoapClient ww = new ServiceReference2.DomesticAirlineSoapClient("DomesticAirlineSoap");
DataSet s = new DataSet();
s = ww.getDomesticAirlinesTime(textBox2.Text,textBox3.Text,textBox4.Text,string.Empty);
int RowCount = s.Tables[].Rows.Count;
int ColumnCount = s.Tables[].Columns.Count;
for (int i = ; i < RowCount; i++)
{
string itemName = s.Tables[].Rows[i][].ToString();
ListViewItem item = new ListViewItem(itemName, i);
//循环每一列
for (int j = ; j < ColumnCount; j++)
{
item.SubItems.Add(s.Tables[].Rows[i][j].ToString());
}
listView1.Items.Add(item);
}
}
private void button4_Click(object sender, EventArgs e)
{
ServiceReference2.DomesticAirlineSoapClient ww = new ServiceReference2.DomesticAirlineSoapClient("DomesticAirlineSoap");
DataSet s = new DataSet();
s = ww.getDomesticCity();
int RowCount = s.Tables[].Rows.Count;
int ColumnCount = s.Tables[].Columns.Count;
for (int i = ; i < RowCount; i++)
{
string itemName = s.Tables[].Rows[i][].ToString();
ListViewItem item = new ListViewItem(itemName, i);
//循环每一列
for (int j = ; j < ColumnCount; j++)
{
item.SubItems.Add(s.Tables[].Rows[i][j].ToString());
}
listView2.Items.Add(item);
}
}
4.最后结果:(和上一次的弄一起了)

C#调用webservice(二)的更多相关文章
- ASP.NET实现二维码 ASP.Net上传文件 SQL基础语法 C# 动态创建数据库三(MySQL) Net Core 实现谷歌翻译ApI 免费版 C#发布和调试WebService ajax调用WebService实现数据库操作 C# 实体类转json数据过滤掉字段为null的字段
ASP.NET实现二维码 using System;using System.Collections.Generic;using System.Drawing;using System.Linq;us ...
- iOS 开发之路(登陆验证调用WebService)二
swift3.0下使用Alamofire调用Webservice遇到的一些问题以及解决方案. 首先是针对没有证书的https下的接口处理问题(ps:不推荐在正式版本中使用),manager.reque ...
- java接口调用——webservice就是一个RPC而已
很多新手一听到接口就蒙逼,不知道接口是什么!其实接口就是RPC,通过远程访问别的程序提供的方法,然后获得该方法执行的接口,而不需要在本地执行该方法.就是本地方法调用的升级版而已,我明天会上一篇如何通过 ...
- C# 调用webservice 几种办法(转载)
原文地址: http://www.cnblogs.com/eagle1986/archive/2012/09/03/2669699.html //=========================== ...
- 【Java EE 学习 80 下】【调用WebService服务的四种方式】【WebService中的注解】
不考虑第三方框架,如果只使用JDK提供的API,那么可以使用三种方式调用WebService服务:另外还可以使用Ajax调用WebService服务. 预备工作:开启WebService服务,使用jd ...
- C#调用WebService
1.1.Web Service基本概念 Web Service也叫XML Web Service WebService是一种可以接收从Internet或者Intranet上的其它系统中传递过来的请求, ...
- Atitit 动态调用webservice与客户端代理方式调用
Atitit 动态调用webservice与客户端代理方式调用 方式1: 使用call.invoke 直接调用WSDL,缺点:麻烦,不推荐--特别是JAVA调用.NET的WS时,会有不少的问题需要解 ...
- 调用webservice 总结
最近做一个项目,由于是在别人框架里开发app,导致了很多限制,其中一个就是不能直接引用webservice . 我们都知道,调用webserivice 最简单的方法就是在 "引用" ...
- C#调用WebService (转)
1.1.Web Service基本概念 Web Service也叫XML Web Service WebService是一种可以接收从Internet或者Intranet上的其它系统中传递过来的请求, ...
随机推荐
- Mongo——C#操作
自己练手写了一个MongoDb的泛型类,顺便把一些常用命令整理了一下,做个记录: /// <summary> /// Mongo操作类. /// </summary> /// ...
- Spark RDD概念学习系列之如何创建RDD
不多说,直接上干货! 创建RDD 方式一:从集合创建RDD (1)makeRDD (2)Parallelize 注意:makeRDD可以指定每个分区perferredLocations参数,而para ...
- C#、SQL中的事务
c#方法一: TransactionOptions transactionOption = new TransactionOptions(); //设置事务隔离级别 transactionOption ...
- 不得了,微软原生提供 AI 人工智能 API,而且面向网页开放
微软原生人工智能(AI) API 不得了,微软原生提供 AI 人工智能 API,而且面向网页开放
- Excel导入到DataTable ,DataTable导入到Excel
using System; using System.Collections.Generic; using System.Linq; using System.Text; using NPOI.SS. ...
- SwipeRefreshLayout的使用,下拉刷新
1. <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android ...
- iOS性能优化专题
http://wereadteam.github.io/2016/05/03/WeRead-Performance/ https://www.cnblogs.com/oc-bowen/p/599999 ...
- ABBYY简体中文版终身授权半价来袭,真的是5折!
经过了一个春秋,心心念念的双十一终于要来了,一年时间并不长,但这一个月尤其慢!ABBYY官方称为回馈广大用户的支持与厚爱,双十一期间,ABBYY价格感人,诱惑难挡. 说到双十一活动,方式也是五花八门, ...
- jquery @keyframes 动态添加
需要写一个css3的动画效果,且需要按着写的事件同事进行需控制样式 css代码 @keyframes spin1 { 0% { transform: rotate(225deg); } 50% { t ...
- ZJU 2676 Network Wars
Network Wars Time Limit: 5000ms Memory Limit: 32768KB This problem will be judged on ZJU. Original I ...