OperationContractAttribute.Name 属性   
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置操作的名称。
public:
 property System::String ^ Name { System::String ^ get(); void set(System::String ^ value); };public string Name { get; set; }member this.Name : string with get, setPublic Property Name As String属性值
操作的名称。
例外
              Name 为 null。
该值是一个空字符串。
示例
下面的代码示例使用 Name 属性声明在元数据中公开的操作名称。
using System;
using System.Collections.Generic;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.Text;
namespace Microsoft.WCF.Documentation
{
  [ServiceContract(Namespace="http://Microsoft.WCF.Documentation")]
  public interface ISampleService{
    [OperationContract(
      Action="http://Microsoft.WCF.Documentation/OperationContractMethod",
      Name="OCAMethod",
      ReplyAction="http://Microsoft.WCF.Documentation/ResponseToOCAMethod"
    )]
    string SampleMethod(string msg);
    [OperationContractAttribute(Action = "*")]
    void UnrecognizedMessageHandler(Message msg);
  }
  class SampleService : ISampleService
  {
    public string  SampleMethod(string msg)
    {
      Console.WriteLine("Called with: {0}", msg);
        return "The service greets you: " + msg;
    }
    public void UnrecognizedMessageHandler(Message msg)
    {
      Console.WriteLine("Unrecognized message: " + msg.ToString());
    }
  }
}
Imports System.ServiceModel
Imports System.ServiceModel.Channels
Imports System.Text
Namespace Microsoft.WCF.Documentation
  <ServiceContract(Namespace:="http://Microsoft.WCF.Documentation")> _
  Public Interface ISampleService
        <OperationContract(Action:="http://Microsoft.WCF.Documentation/OperationContractMethod", _
                           Name:="OCAMethod", ReplyAction:="http://Microsoft.WCF.Documentation/ResponseToOCAMethod")> _
        Function SampleMethod(ByVal msg As String) As String
    <OperationContractAttribute(Action := "*")> _
    Sub UnrecognizedMessageHandler(ByVal msg As Message)
  End Interface
  Friend Class SampleService
      Implements ISampleService
    Public Function SampleMethod(ByVal msg As String) As String Implements ISampleService.SampleMethod
      Console.WriteLine("Called with: {0}", msg)
         Return "The service greets you: " & msg
    End Function
    Public Sub UnrecognizedMessageHandler(ByVal msg As Message) Implements ISampleService.UnrecognizedMessageHandler
      Console.WriteLine("Unrecognized message: " & msg.ToString())
    End Sub
  End Class
End Namespace
注解
              Name使用 属性替代 <operation> WSDL 中的元素名称。 默认的操作名称为实现方法的名称。