OperationContractAttribute In WCF

In this article, we will be discussing the OperationContractAttribute, which is the part of the Service Contract. It is defined in the System.ServiceModel namespace. It is used to specify the Service Description.

Now we will discuss the properties of the OperationContract Attribute:

  1. AsyncPattern

    It is used to define how the operation is implemented, whether asynchronously or not. Asynchronous means we use Begin<MethodName> and End<MethodName> in our service contract. It returns true if the pattern is used in the program, otherwise it returns false. It is useful when the server wants to return some data to the client after a lengthy operation.
  2. ProtectionLevel

    It is used to specify a protection level (encrypted, signed or both) to the messages of the operation.
  3. HasProtectionLevel

    It is used to define that the operation has a protection level or not.
  4. Action

    It is used to send a request message to the appropriate method. It is the combination of Contract namespace, Contract Name, the operation name and an optional string (Response).
  5. ReplyAction

    It is used to define the action of the Reply message.
  6. IsOneWay

    It is used to define that the operation does not return or reply to the message. If it is true, the method receives a message that it does not reply to.
  7. IsInitiating

    It is used to define that the method implements an operation which is useful for initiating a session on the service. If we set it to false then that means the client must call another method on the service.
  8. IsTerminating

    It is used to terminate the communication session. In the case of the client, if it is true then the channel will be closed after the message arrives. And in the service, a timer will be set; it aborts the channel, if the client does not close the communication in the specified time period.

Similar Articles