c#編寫webservice服務(wù)引用實例分享
首先在新建了一個web服務(wù)文件。
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
然后自己調(diào)用自己的sqlhelper類中的方法,實現(xiàn)對數(shù)據(jù)的基本操作,其實和我們在bll中的調(diào)用一樣,只不過通過[WebMethod]把自己所定義的方法暴露出來供外部調(diào)用,[WebMethod(Description="添加操作")]中的Description屬性標(biāo)注了對改方法的作用,同時在weiservice頁面中顯示出來。
[WebMethod(Description="添加操作")]
public ResultModel AddData(string sql, SqlParameter[] sp)
{
return WhhSqlHelper.Intersql(sql, sp);
}
/// <summary>
/// 執(zhí)行更新操作
/// </summary>
/// <param name="sql"></param>
/// <param name="sp"></param>
/// <returns></returns>
[WebMethod(Description = "修改操作")]
public ResultModel Updata(string sql,SqlParameter[] sp)
{
return WhhSqlHelper.UpdateSql(sql, sp);
}
[WebMethod(Description = "查詢操作")]
public ResultModel selectSQL(string sql,SqlParameter[]sp)
{
return WhhSqlHelper.SingSelectSql(sql, sp);
}
[WebMethod(Description = "刪除操作")]
public ResultModel Delete(string sql,SqlParameter[] sp)
{
return WhhSqlHelper.DeleteSql(sql,sp);
}
[WebMethod(Description = "是否存在操作")]
public ResultModel IsExistent(string sql, SqlParameter[] sp)
{
return WhhSqlHelper.IsExistent(sql, sp);
}
這些只是對基本的數(shù)據(jù)操作的web調(diào)用,還可以針對一些公共功能給提煉出來進(jìn)行web封裝,比如說,不同表的增刪改查,這些都可以的把封裝到一起。
其中的 WhhSqlHelper是我寫的一個sqlhelper類,ResultModel是我寫的一個數(shù)據(jù)操作的返回實體Model.
- C#調(diào)用webservice接口的最新方法教程
- C#使用HttpPost請求調(diào)用WebService的方法
- .NET C#創(chuàng)建WebService服務(wù)簡單實例
- C# 創(chuàng)建、部署和調(diào)用WebService簡單示例
- C# WebService發(fā)布以及IIS發(fā)布
- C# 調(diào)用 JavaWebservice服務(wù)遇到的問題匯總
- C#調(diào)用WebService實例開發(fā)
- C#動態(tài)webservice調(diào)用接口
- C#使用WebService結(jié)合jQuery實現(xiàn)無刷新翻頁的方法
- c#動態(tài)改變webservice的url訪問地址
- c#動態(tài)調(diào)用Webservice的兩種方法實例
- C#創(chuàng)建、部署、調(diào)用WebService圖文實例詳解
相關(guān)文章
C#簡單訪問SQLite數(shù)據(jù)庫的方法(安裝,連接,查詢等)
這篇文章主要介紹了C#簡單訪問SQLite數(shù)據(jù)庫的方法,涉及SQLite數(shù)據(jù)庫的下載、安裝及使用C#連接、查詢SQLIte數(shù)據(jù)庫的相關(guān)技巧,需要的朋友可以參考下2016-07-07.net C# 實現(xiàn)任意List的笛卡爾乘積算法代碼
笛卡爾(Descartes)乘積又叫直積。假設(shè)集合A={a,b},集合B={0,1,2},則兩個集合的笛卡爾積為{(a,0),(a,1),(a,2),(b,0),(b,1), (b,2)}。2013-05-05