WebService 使用多載
今天有需要..用到這功能..改下面這兩個部份..就行了..^^..
[WebMethod(MessageName = "msg")]
[WebServiceBinding(ConformsTo = WsiProfiles.None)]
看原始碼..
using System; using System.Collections; using System.Linq; using System.Web; using System.Web.Services; using System.Web.Services.Protocols; using System.Xml.Linq; /// <summary> /// Summary description for WebService /// </summary> [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.None)] // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. // [System.Web.Script.Services.ScriptService] public class WebService : System.Web.Services.WebService { public WebService() { //Uncomment the following line if using designed components //InitializeComponent(); } //建立兩個webmethod [WebMethod(MessageName = "oInt")] public int getInt() { return 10; } [WebMethod(MessageName = "nInt")] public int getInt(int aa) { return 10 + aa; } }