??? public class CalCulService : System.Web.Services.WebService?
??? {?
?
??????? [WebMethod]?
??????? public string HelloWorld()?
??????? {?
??????????? return "Hello World";?
??????? }?
??? }?
}?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;namespace CalculateService
{/// <summary>/// WebService1 的摘要說明/// </summary>[WebService(Namespace = "http://tempuri.org/")][WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)][System.ComponentModel.ToolboxItem(false)]// 若要允許使用 ASP.NET AJAX 從腳本中調用此 Web 服務,請取消注釋以下行。 // [System.Web.Script.Services.ScriptService]public class CalCulService : System.Web.Services.WebService{[WebMethod]public string HelloWorld(){return "Hello World";}}
}
??? public class CalCulService : System.Web.Services.WebService?
??? {???????
??????? [WebMethod]?
??????? public int Sum(int a, int b)?
??????? {?
??????????? return a + b;?
??????? }?
?
??????? [WebMethod]?
??????? public int Sub(int a, int b)?
??????? {?
??????????? return a - b;?
??????? }?
?
??????? [WebMethod]?
??????? public double Mult(double a, double b)?
??????? {?
??????????? return a * b;?
??????? }?
?
??????? [WebMethod]?
??????? public double Div(double a, double b)?
??????? {?
??????????? return a / b;?
??????? }?
??? }?
}?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;namespace CalculateService
{/// <summary>/// CalCulService 的摘要說明/// </summary>[WebService(Namespace = "http://login.wxjy.info")][WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)][System.ComponentModel.ToolboxItem(false)]// 若要允許使用 ASP.NET AJAX 從腳本中調用此 Web 服務,請取消注釋以下行。 // [System.Web.Script.Services.ScriptService]public class CalCulService : System.Web.Services.WebService{ [WebMethod]public int Sum(int a, int b){return a + b;}[WebMethod]public int Sub(int a, int b){return a - b;}[WebMethod]public double Mult(double a, double b){return a * b;}[WebMethod]public double Div(double a, double b){return a / b;}}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;//不要忘記為WebService添加using引用
using TestCalCul.MyWebService;namespace TestCalCul
{public partial class WebForm1 : System.Web.UI.Page{protected void Page_Load(object sender, EventArgs e){CalCulService cal = new CalCulService();double a = 29755;double b = 112.58;Response.Write(cal.Mult(a, b).ToString());}}
}