本文整理汇总了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);
}
}