WCF Operation Contract

In this article I am going to explain about WCF Operation contract. It is one of the WCF contracts. The public method marked as [OperationContract] get exposed to service clients. The OperationContractAttribute belongs System.ServiceModel namespace.

OperationContractAttribute has below properties


Gets or sets Operation Contract's name. You can specify different name for the operation using this property. By default the name of operation will be your method name.

[ServiceContract ]
public interface IStudentService
String GetStudentIdentity(int studentId);


Action And Reply Action

The OperationContract Action and Reply action values are co related messages with operation. It gives you explicit control on header of soap messages and response messages. These properties provide URI as the address of an operation. The action property provides incoming message whereas Reply action provide outgoing message and WCF dispatcher will route it as per the action value of operations.

public interface IStudentService{
Name=" GetStudent ",
string StudentDetails(string msg);



It is Boolean property when you set it as True your operation uses Oneway MEP. It does not return any data, fault exception. Reply action is not supported if you are using IsOneWay = True. For more detail on MEP please Check


Protection Level

It controls how your message will be protected. There are three available choices to set this property.

None: Message will not secured by signing or encrypting it on wire. The message will be flow in plain text.

Sign: The request and response messages will be digitally signed and ensures there is no tampering while message transfer on wire.

EncryptAndSign: Request and response messages will be encrypted and then signed.

If you want to use the protection level as Sign or EnccryptAndSign then you will have to use the binding which supports security and enable it in binding settings otherwise it will throw the exception.

If Bindings security mode has set to transport then the OperationContract's Protection Level has no effect.

public interface IStudentMarks
[OperationContract(ProtectionLevel = ProtectionLevel.Sign)]
Student GetStudentMarks();



This is Boolean property. If you set to true whenever new session created for service this operation method will get execute first and then requested operation method. For making use of this property the ServiceContracts Session mode property should be Allowed or Required and you should use the bindings which supports Sessions (Read more on Service Contract).



This is Boolean property. If you set it to true and clients operation call involves the terminating of Session then this operation contract will come in pipeline after requested operation, opposite of IsInitiating.


No responses found. Be the first to comment...

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: