C#写webservice服务引用
来源:互联网 发布:香港网络运营商有几家 编辑:程序博客网 时间:2024/05/17 22:35
我在自己试着写了一个sqlhelper以后,在这个项目的基础上写了一个webservice的服务引用。由于是第一次写,也只是观摩着别人的写。
首先在新建了一个web服务文件。
public SqlWhhWebService1() { InitializeComponent(); } #region Component Designer generated code //Required by the Web Services Designer private IContainer components = null; /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { } /// <summary> /// Clean up any resources being used. /// </summary> protected override void Dispose(bool disposing) { if (disposing && components != null) { components.Dispose(); } base.Dispose(disposing); } #endregion
然后自己调用自己的sqlhelper类中的方法,实现对数据的基本操作,其实和我们在bll中的调用一样,只不过通过[WebMethod]把自己所定义的方法暴露出来供外部调用,[WebMethod(Description="添加操作")]中的Description属性标注了对改方法的作用,同时在weiservice页面中显示出来。
View Code
1 [WebMethod(Description="添加操作")] 2 public ResultModel AddData(string sql, SqlParameter[] sp) 3 { 4 return WhhSqlHelper.Intersql(sql, sp); 5 } 6 /// <summary> 7 /// 执行更新操作 8 /// </summary> 9 /// <param name="sql"></param>10 /// <param name="sp"></param>11 /// <returns></returns>12 [WebMethod(Description = "修改操作")]13 public ResultModel Updata(string sql,SqlParameter[] sp)14 {15 return WhhSqlHelper.UpdateSql(sql, sp);16 }17 [WebMethod(Description = "查询操作")]18 public ResultModel selectSQL(string sql,SqlParameter[]sp)19 {20 return WhhSqlHelper.SingSelectSql(sql, sp);21 }22 [WebMethod(Description = "删除操作")]23 public ResultModel Delete(string sql,SqlParameter[] sp)24 {25 return WhhSqlHelper.DeleteSql(sql,sp);26 }27 [WebMethod(Description = "是否存在操作")]28 public ResultModel IsExistent(string sql, SqlParameter[] sp)29 {30 return WhhSqlHelper.IsExistent(sql, sp);31 }
这些只是对基本的数据操作的web调用,还可以针对一些公共功能给提炼出来进行web封装,比如说,不同表的增删改查,这些都可以的把封装到一起。
其中的 WhhSqlHelper是我写的一个sqlhelper类,ResultModel是我写的一个数据操作的返回实体Model.
<script type="text/javascript"><!--google_ad_client = "ca-pub-1944176156128447";/* cnblogs 首页横幅 */google_ad_slot = "5419468456";google_ad_width = 728;google_ad_height = 90;//--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
- C#写webservice服务引用
- 如何用WcfTestClient.exe测试C#写的WebService服务
- c# 写 webservice接口
- C# webService服务
- C#写Webservice并发布
- C# 写windows服务
- C#写windows服务
- c#写windows 服务
- C#写Windows服务
- c#写windows服务
- c#写windows服务
- C#写windows服务
- 不通过“添加引用服务”调用WebService接口
- C# 动态生成WebService 的引用
- C#不添加引用,动态调用webservice
- C#不添加引用,动态调用webservice .
- C#不添加引用,动态调用webservice
- C# 不用添加WebService引用,调用WebService方法
- poj 3917 Rock, Paper, Scissors
- 7 套接字选项
- 第四周项目五选作3
- java 服务降级开关设计思路
- 换种方式学编程:如何训练你的机器人
- C#写webservice服务引用
- 骨骼图像增强实验matlab实现
- PHP正则表达式(1):匹配字符串不能包含中文
- SWT:分割窗口
- Java集合的排序和HashCode方法详解
- android 拍照指定存储路径 检查SD卡状态
- linux内核配置文件.config,基于s3c2410实现
- 求含n个顶点的多边形面积
- 二分查找算法