zoukankan      html  css  js  c++  java
  • 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());
            }
  • 相关阅读:
    hdu 1754 线段树 注意线段树节点的设计 求什么,设什么
    hdu 4015 概率题
    poj 1950 回溯
    最大上升子序列
    JVM学习博客
    2012
    i am alone at a crossroads
    易知难
    牢骚。。
    something
  • 原文地址:https://www.cnblogs.com/flywing/p/7279903.html
Copyright © 2011-2022 走看看