标签:list 使用 app method eric services getc ret toolbox
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Services; namespace StudentWebserice { using MODEL; using BLL; using System.Data.SqlClient; using Newtonsoft.Json; using System.Data; /// <summary> /// ClassWebService 的摘要说明 /// </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 ClassWebService : System.Web.Services.WebService { [WebMethod] public string HelloWorld() { return "Hello World"; } [WebMethod] public void GetClasses(int SchoolCode) { ClassBll bll = new ClassBll(); Context.Response.ContentType = "Application/json;charset=utf-8"; List<Class> list = bll.GetClasses(SchoolCode); var json = JsonConvert.SerializeObject(list); Context.Response.Write(json); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Services; namespace StudentWebserice { using MODEL; using BLL; using System.Data.SqlClient; using Newtonsoft.Json; using System.Data; /// <summary> /// StudentWebserice 的摘要说明 /// </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 StudentWebserice : System.Web.Services.WebService { [WebMethod] public string HelloWorld() { return "Hello World"; } [WebMethod] public void GetSchools() { SchoolBll bll = new SchoolBll(); Context.Response.ContentType = "Application/json;charset=utf-8"; List<School> list = bll.GetSchools(); var json = JsonConvert.SerializeObject(list); Context.Response.Write(json); } } }
标签:list 使用 app method eric services getc ret toolbox
原文地址:https://www.cnblogs.com/mamingyuan/p/9387962.html