質問

What is a WCF OperationContract? I dont really understand what it does

役に立ちましたか?

解決

WCF uses an opt-in model to define what belongs to one of its contracts. In a service contract interface, only methods decorated with [OperationContract] are exposed to the client. That means that, in the interface below, if used within a WCF service, a client could call both Add and Subtract operations, but not Multiply.

[ServiceContract]
public interface ICalculator
{
    [OperationContract]
    int Add(int x, int y);

    [OperationContract]
    int Subtract(int x, int y);

    // Not decorated
    int Multiply(int x, int y);
}

他のヒント

Every method you want to be able to the user calling from his client side must be declared like that.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top