zoukankan      html  css  js  c++  java
  • net Web Service 方法重载

    在Web service 中重载方法,默认是不支持的,这是因为WebMethod特性的MessageName属性使XML Web services能够唯一确定使用别名的重载方法。除非另外指定,默认值是方法名称。当指定MessageName时,结果SOAP消息将反映该名称,而不是实际的方法名称。下面是我用的Webservice 方法的重载:

    namespace WebMothed_重载 {
        ///
        /// Summary description for Service1
        ///
        [WebService(Namespace = "http://tempuri.org/")]
        [WebServiceBinding(ConformsTo = WsiProfiles.None)]
        [ToolboxItem(false)]
        public class Service1 : System.Web.Services.WebService {
            [WebMethod(MessageName="a")]
            public string HelloWorld() {
                return "Hello World";
            }
            [WebMethod(MessageName="b")]
            public string HelloWorld(string str) {
                return "Hello World"+str;
            }
        }
    }
    主要注意修改两个地方:
     1、修改方法属性MessageName
             [WebMethod(MessageName="a")]
            public string HelloWorld() {
                return "Hello World";
            }
            [WebMethod(MessageName="b")]
            public string HelloWorld(string str) {
                return "Hello World"+str;
            }
    2、修改类属性ConformsTo
            [WebService(Namespace = "http://tempuri.org/")]
        [WebServiceBinding(ConformsTo = WsiProfiles.None)]
        [ToolboxItem(false)]
        public class Service1 : System.Web.Services.WebService         {...}
  • 相关阅读:
    三连击
    铺地毯
    超级玛丽游戏
    A+B problem
    怎么感觉欠缺点什么、灵光在哪,让我顿悟下
    2016年10月,人生的转折点。
    python第七天
    python第六天
    汉诺塔问题(Hanoi Tower)递归算法解析(Python实现)
    计算多数的乘积(Python实现)
  • 原文地址:https://www.cnblogs.com/ilahsa/p/1189059.html
Copyright © 2011-2022 走看看