• webservice简单例子


    1、添加web服务。

    /// <summary>
        /// demo 的摘要说明
        /// </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 demo : System.Web.Services.WebService
        {
    
            [WebMethod]
            public string HelloWorld()
            {
                return "Hello World";
            }
    
            [WebMethod]
            public int GetSum(int a, int b)
            {
                return a + b;
            }
        }

    2、添加服务引用:地址为上一步添加的web服务访问地址,高级=》添加web引用=》添加引用。

    3、调用

    public ActionResult GetSum(int a, int b)
            {
                localhost.demo s = new localhost.demo();
                var sum = s.GetSum(a, b);
                return Content(sum.ToString());
            }
  • 相关阅读:
    禁止root远程登录解决办法
    小肥羊
    高级英语
    通用做饭general
    2021/03/10,创新与毁灭
    pandaExpressRound2
    2021/03/08,经历建立的你
    系统与细节
    报税
    事业portfolio
  • 原文地址:https://www.cnblogs.com/flywing/p/7279903.html
Copyright © 2020-2023  润新知