Click here to Skip to main content
15,892,072 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Why OperationContract attribute required in WCF service function?

e.g

C#
[OperationContract]
public void DoWork()
{
    // Add your operation implementation here
    return;
}

// Add more operations here and mark them with [OperationContract]
Posted
Updated 15-Oct-11 2:27am
v6

You might want to start reading some books on WCF.
Here is a very basic read[^] that should give you some idea.
As this msdn link suggests, the OperationContractAttribute attribute declares that a method is an operation in a service contract.
 
Share this answer
 
Indicates that a method defines an operation that is part of a service contract in a Windows Communication Foundation (WCF) application.

the OperationContractAttribute properties to control the structure of the operation and the values expressed in metadata:

The Action property specifies the action that uniquely identifies this operation. WCF dispatches request messages to methods based on their action.

The AsyncPattern property indicates that the operation is implemented or can be called asynchronously using a Begin/End method pair.

The HasProtectionLevel property indicates whether the ProtectionLevel property has been explicitly set.

The IsOneWay property indicates that the operation only consists of a single input message. The operation has no associated output message.

The IsInitiating property specifies whether this operation can be the initial operation in a session.

The IsTerminating property specifies whether WCF attempts to terminate the current session after the operation completes.

The ProtectionLevel property specifies the message-level security that an operation requires at run time.

The ReplyAction property specifies the action of the reply message for the operation
 
Share this answer
 
because operation contract serialize method on network.
without attribute method can't access on client application
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900