[System.Web.Script.Services.ScriptService] public class WebService : System.Web.Services.WebService { public WebService () { //如果使用设计的组件,请取消注释以下行 //InitializeComponent(); } [WebMethod] public string GetWhether(string cityId) { Random r = new Random(); int degree = r.Next(100); string wInfo = string.Format("Today {0}'s temperature is {1} degrees", cityId, degree); return wInfo; } }