header image

Tutorial Windows Communication Foundation (WCF) – ServiceContract & OperationContract – Attributes

Posted by: | July 20, 2009 | 7 Comments |

ServiceContractAttribute 


  • Name  and Namespace – The name and namespace are the optional attibutes. Default name is same as the contract type and namespace is http://tempuri.org. It is always recommondable to use Namespace to specify proper namespace which remove the conflict of the datatype/contract.
  • CallbackContract – Return contract in a two-way (duplex) conversation.
  • HasProtectionLevel and ProtectionLevel – Specifies whether all messages supporting the contract have a explicit ProtectionLevel value.
    Default ProtectionLevel is ProtectionLevel.None.
  • ConfigurationName – The name of the service element in the configuration file to use.
  • SessionMode – This is to specify whether the contract requires a binding that supports sessions.

OperationContractAttribute


  • Name: The name of an operation is part of a service contract. Default is the method name.
  • Action: The send message dispatches to the method for the operation based on action.
  • ReplyAction: To specify the reply message
  • IsOneWay: Specifies whether the operation is one directional that an does not return a reply message. This is commonly used for notification service.
  • ProtectionLevel
  • IsInitiating: Specifies if the operation is the intial operation in a session. 
  • IsTerminating: Specifies if the session will be terminated after the operation
  • AsyncPattern: To asynchronously using a Begin/End method pair
under: 11143, 9534, 9536