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, set
Public 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 中的專案名稱。 預設作業名稱是實作方法的名稱。