从Webservice获得泛型集合
来源:互联网 发布:淘宝助理无数据 编辑:程序博客网 时间:2024/06/05 00:47
1。先建立模型层:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Air.Model
{
public class City
{
private int _cityId;
public int CityId
{
get { return _cityId; }
set { _cityId = value; }
}
private string _cityName;
public string CityName
{
get { return _cityName; }
set { _cityName = value; }
}
private string _districtCode;
public string DistrictCode
{
get { return _districtCode; }
set { _districtCode = value; }
}
}
}
2.。Webservice 反射方法
using System;
using System.Data;
using System.Linq;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;
using System.Collections.Generic;
using Air.Model;
namespace Air.AirService
{
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
public class AirService : System.Web.Services.WebService
{
[WebMethod]
public List<City> GetCitys()
{
List<City> citys = new List<City>();
return citys;
}
}
3。引用Web服务
如果为同一项目中使用则选择Web Services in this solution
如果为本地调用则选择Web services on the local machine
如果远程调用则悬在Browse UDDI Servers on the local network
选择所需要的web服务
更改web资源名称,并点击添加web引用
4。调用web方法
public void DataBind() {
AirService.AirService airService = new Air.AirService.AirService();
List<City> DataSource = airService.GetCitys();
}
如上为webservice返回泛型集合的方法,需要注意的是webservice只能返回类型而不能返回接口,如果使用IList<T>则会出现无法序列化对象错误。
- 从Webservice获得泛型集合
- Webservice - 泛型或集合 - EnterpriseLibrary
- JAVA基础知识——从Map中获得Key集合及Value集合
- java获得天气预报-webservice
- java获得天气预报-webservice
- WebService获得服务器时间
- 如何获得一个未声明泛型集合的泛型类型?
- WP7 webservice问题集合
- Java6 WebService 使用集合
- webservice递归集合
- webservice之获得随机汉字
- 从CWsScreenDevice获得CFbsScreenDevice
- 从 URL 调用 WebService
- MatchCollection获得一系列数据集合
- C#+Arcengine获得点集合
- 获得Mxd中的Map集合
- Spring 集合cxf发布webservice
- 从一个增强型的栈上 获得的启示
- c语言实现dos命令dir dir/s 目录遍历
- struts+hibernate+pager-taglib 分页
- 32个最热CPLD-FPGA论坛[zz]
- 使用delegate类型设计自定义事件
- 获取两个整型数组之间的重复元素集合
- 从Webservice获得泛型集合
- 2-17作业
- mangos数据库UDB
- 心有千千结(一)
- 影响未来5年全球半导体和电子行业的十大因素
- 全面解析jdbc
- 软件史上最伟大的十大程序员
- 心有千千结(二)
- 2007年度调查揭开嵌入式市场的真相!