首先在新建了一個web服務文件。
//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類中的方法,實現(xiàn)對數(shù)據(jù)的基本操作,其實和我們在bll中的調用一樣,只不過通過[WebMethod]把自己所定義的方法暴露出來供外部調用,[WebMethod(Description="添加操作")]中的Description屬性標注了對改方法的作用,同時在weiservice頁面中顯示出來。
這些只是對基本的數(shù)據(jù)操作的web調用,還可以針對一些公共功能給提煉出來進行web封裝,比如說,不同表的增刪改查,這些都可以的把封裝到一起。
其中的 WhhSqlHelper是我寫的一個sqlhelper類,ResultModel是我寫的一個數(shù)據(jù)操作的返回實體Model.
|
新聞熱點
疑難解答