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         {...}
  • 相关阅读:
    React 高阶组件
    Facebook Graph API 接口请求
    (转载)HTML:模拟链接被按下,在新标签页打开页面,不使用window.open(可能被拦截)
    php file_put_contents() 写入回车
    mysql 慢查询开启
    FB接口之 js调用支付窗口
    8 个必备的PHP功能开发
    linux 负载 待读
    大话团队管理。
    API编排
  • 原文地址:https://www.cnblogs.com/gebenhagen/p/1694849.html
Copyright © 2011-2022 走看看