Export (0) Print
Expand All

OperationDescription Class

Represents the description of a contract operation that provides a description of the messages that make up the operation.

System.Object
  System.ServiceModel.Description.OperationDescription

Namespace:  System.ServiceModel.Description
Assembly:  System.ServiceModel (in System.ServiceModel.dll)

public class OperationDescription

The OperationDescription type exposes the following members.

  NameDescription
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsOperationDescriptionInitializes a new instance of the OperationDescription class with a specified name and contract description.
Top

  NameDescription
Public propertySupported by Portable Class LibraryBeginMethodGets or sets the begin method of the operation.
Public propertyBehaviorsGets or sets the operation behaviors associated with the operation.
Public propertySupported by Portable Class LibrarySupported in .NET for Windows Store appsDeclaringContractGets or sets the contract to which the operation belongs.
Public propertySupported by Portable Class LibraryEndMethodGets or sets the end method of the operation.
Public propertySupported by Portable Class LibrarySupported in .NET for Windows Store appsFaultsGets the descriptions of the faults associated with the operation description.
Public propertyHasProtectionLevelGets a value that indicates whether the operation has had a protection level set.
Public propertyIsInitiatingGets or sets a value that indicates whether the method implements an operation that can initiate a session on the server (if such a session exists).
Public propertySupported by Portable Class LibrarySupported in .NET for Windows Store appsIsOneWayGets or sets a value that indicates whether an operation returns a reply message.
Public propertyIsTerminatingGets or sets a value that indicates whether the service operation causes the server to close the session after the reply message, if any, is sent.
Public propertySupported by Portable Class LibrarySupported in .NET for Windows Store appsKnownTypesGets the known types associated with the operation description.
Public propertySupported by Portable Class LibrarySupported in .NET for Windows Store appsMessagesGets or sets the descriptions of the messages that make up the operation.
Public propertySupported by Portable Class LibrarySupported in .NET for Windows Store appsNameGets or sets the name of the operation description.
Public propertySupported in .NET for Windows Store appsOperationBehaviorsGets the set of behaviors for the operation.
Public propertyProtectionLevelGets or sets the protection level for the operation.
Public propertySupported by Portable Class LibrarySyncMethodGets or sets the service synchronization method of the operation description.
Public propertySupported in .NET for Windows Store appsTaskMethodGets or sets the method used for the task operation.
Top

  NameDescription
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodShouldSerializeProtectionLevelReturns a value that indicates whether the ProtectionLevel property has changed from its default value and should be serialized.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsToStringReturns a string that represents the current object. (Inherited from Object.)
Top

A Windows Communication Foundation (WCF) contract is a collection of operations that specifies what the endpoint communicates to the outside world. Each operation is a message exchange. For example, a request message and an associated reply message forming a request/reply message exchange.

A ContractDescription object is used to describe contracts and their operations. Within a ContractDescription, each contract operation has a corresponding OperationDescription that describes aspects of the operation, such as whether the operation is one-way or request/reply. Each OperationDescription also describes the messages that make up the operation using a collection of MessageDescription objects. ContractDescription contains a reference to an interface that defines the contract using the programming model. This interface is marked with ServiceContractAttribute, and its methods that correspond to endpoint operations are marked with OperationContractAttribute.

Many of the properties on OperationDescription have corresponding properties in the WCF programming model on OperationContractAttribute, for example, IsTerminating.

The following example uses the OperationDescription returned from the collection returned by the Operations property of the ContractDescription class. The code iterates through the collection of endpoints and prints each endpoint name, as well as the name of each operation in the endpoint.

private void PrintDescription(ServiceHost sh)
{
    // Declare variables. 
    int i, j, k, l, c;
    ServiceDescription servDesc = sh.Description;
    OperationDescription opDesc;
    ContractDescription contractDesc;
    MessageDescription methDesc;
    MessageBodyDescription mBodyDesc;
    MessagePartDescription partDesc;
    IServiceBehavior servBeh;
    ServiceEndpoint servEP;

    // Print the behaviors of the service.
    Console.WriteLine("Behaviors:");
    for (c = 0; c < servDesc.Behaviors.Count; c++)
    {
        servBeh = servDesc.Behaviors[c];
        Console.WriteLine("\t{0}", servBeh.ToString());                
    }

    // Print the endpoint descriptions of the service.
    Console.WriteLine("Endpoints");
    for (i = 0; i < servDesc.Endpoints.Count; i++)
    {
        // Print the endpoint names.
        servEP = servDesc.Endpoints[i];
        Console.WriteLine("\tName: {0}", servEP.Name);
        contractDesc = servEP.Contract;

        Console.WriteLine("\tOperations:");
        for (j = 0; j < contractDesc.Operations.Count; j++)
        {
            // Print the operation names.
            opDesc = servEP.Contract.Operations[j];
            Console.WriteLine("\t\t{0}", opDesc.Name);
            Console.WriteLine("\t\tActions:");
            for (k  = 0; k < opDesc.Messages.Count; k++)
            {
                // Print the message action. 
                methDesc = opDesc.Messages[k];
                Console.WriteLine("\t\t\tAction:{0}", methDesc.Action);

                // Check for the existence of a body, then the body description.
                mBodyDesc = methDesc.Body;
                if (mBodyDesc.Parts.Count > 0)
                {
                    for (l = 0; l < methDesc.Body.Parts.Count; l++)
                    {
                        partDesc = methDesc.Body.Parts[l];
                        Console.WriteLine("\t\t\t\t{0}",partDesc.Name);
                    }
                }
            }
        }
    }
}

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Portable Class Library

Supported in: Portable Class Library

.NET for Windows Store apps

Supported in: Windows 8

.NET for Windows Phone apps

Supported in: Windows Phone 8.1, Windows Phone 8, Silverlight 8.1

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, 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.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2014 Microsoft