using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Services; using System.Web.Script.Services; using System.Web.Script.Serialization; [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [System.Web.Script.Services.ScriptService] public class Service : System.Web.Services.WebService { public Service () {} [WebMethod] [ScriptMethod(ResponseFormat=ResponseFormat.Json)] public string Authenticate(string UserId, string UserPwd) { bool result = true; return new JavaScriptSerializer().Serialize(result); } [WebMethod] [ScriptMethod(ResponseFormat = ResponseFormat.Json)] public string GetUser() { User user = new User(); user.UserId = "jake"; user.UserPwd = "123"; return new JavaScriptSerializer().Serialize(user); } [WebMethod] [ScriptMethod(ResponseFormat = ResponseFormat.Json)] public string GetUsers() { List<User> list = new List<User>(); User user = new User(); user.UserId = "jake"; user.UserPwd = "123"; list.Add(user); user.UserId = "nola"; user.UserPwd = "456"; list.Add(user); return new JavaScriptSerializer().Serialize(list); } } public class User { public string UserId { get; set; } public string UserPwd { get; set; } }