码迷,mamicode.com
首页 > 其他好文 > 详细

学校数据

时间:2018-07-29 23:24:43      阅读:174      评论:0      收藏:0      [点我收藏+]

标签: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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!