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         {...}
  • 相关阅读:
    动手学习TCP:TCP连接建立与终止
    动手学习TCP: 环境搭建
    Python 数据分析4
    Django unittest 单元测试
    Django commands自定制
    Python mac安装mysqlclient的一个bug
    Centos7 开机启动流程
    Centos 06 文件类型和扩展名&索引节点inode和存储块block
    Centos 05 系统目录讲解
    Linux 踩过的坑系列-01
  • 原文地址:https://www.cnblogs.com/gebenhagen/p/1691731.html
Copyright © 2011-2022 走看看