OperationContractAttribute.Name Property
.NET Framework 4.5
Gets or sets the name of the operation.
Assembly: System.ServiceModel (in System.ServiceModel.dll)
| Exception | Condition |
|---|---|
| ArgumentNullException | Name is null. |
| ArgumentOutOfRangeException | The value is an empty string. |
The following code example uses the Name property to declare the name of the operation as exposed in metadata.
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()); } } }
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.