当前位置: 首页>>代码示例>>C#>>正文


C# SoapMethodAttribute类代码示例

本文整理汇总了C#中System.Runtime.Remoting.Metadata.SoapMethodAttribute的典型用法代码示例。如果您正苦于以下问题:C# SoapMethodAttribute类的具体用法?C# SoapMethodAttribute怎么用?C# SoapMethodAttribute使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SoapMethodAttribute类属于System.Runtime.Remoting.Metadata命名空间,在下文中一共展示了SoapMethodAttribute类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetHello

//引入命名空间
using System;
using System.Runtime.Remoting.Metadata;
using System.Security.Permissions;

namespace ExampleNamespace
{
    public class ExampleClass
    {
        [SoapMethod(
             ResponseXmlElementName="ExampleResponseElement",
             ResponseXmlNamespace=
                "http://example.org/MethodResponseXmlNamespace",
             ReturnXmlElementName="HelloMessage",
             SoapAction="http://example.org/ExampleSoapAction#GetHello",
             XmlNamespace="http://example.org/MethodCallXmlNamespace")]
        public string GetHello(string name)
        {
            return "Hello, " + name;
        }
    }
}

public class Demo
{
[SecurityPermission(SecurityAction.Demand)]
    public static void Main(string[] args)
    {
        // Get the method info object for the GetHello method.
        System.Reflection.MethodBase getHelloMethod = 
            typeof(ExampleNamespace.ExampleClass).GetMethod("GetHello");

        // Print the XML namespace for the invocation of this method.
        string methodCallXmlNamespace = 
            System.Runtime.Remoting.SoapServices.
                GetXmlNamespaceForMethodCall(getHelloMethod);
        Console.WriteLine(
            "The XML namespace for the response of the method " +
            "GetHello in ExampleClass is {0}.",
            methodCallXmlNamespace);

        // Print the XML namespace for the response of this method.
        string methodResponseXmlNamespace =
            System.Runtime.Remoting.SoapServices.
                GetXmlNamespaceForMethodResponse(getHelloMethod);
        Console.WriteLine(
            "The XML namespace for the invocation of the method " +
            "GetHello in ExampleClass is {0}.",
            methodResponseXmlNamespace);

        // Print the SOAP action for this method.
        string getHelloSoapAction =
            System.Runtime.Remoting.SoapServices.
                GetSoapActionFromMethodBase(getHelloMethod);
        Console.WriteLine(
            "The SOAP action for the method " +
            "GetHello in ExampleClass is {0}.", 
            getHelloSoapAction);
    }
}
开发者ID:.NET开发者,项目名称:System.Runtime.Remoting.Metadata,代码行数:60,代码来源:SoapMethodAttribute


注:本文中的System.Runtime.Remoting.Metadata.SoapMethodAttribute类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。