开发者

Is it necessary for me to write [OperationContract] over every method in my WCF Service?

开发者 https://www.devze.com 2022-12-28 00:55 出处:网络
For example, is this correct? [OperationContract] bool IsHappy(string userID); bool IsSad(string userID);

For example, is this correct?

[OperationContract]
bool IsHappy(string userID);
bool IsSad(string userID);
bool IsHungry(string userID);

Is that a valid body of operations for a WCF ServiceContract or do I ha开发者_如何学Pythonve to do it this way:

[OperationContract]
bool IsHappy(string userID);

[OperationContract]
bool IsSad(string userID);

[OperationContract]
bool IsHungry(string userID);


You must denote every method that you want to expose from the service with [OperationContract]. You are free to have methods without this attribute in your service class but those methods will not be exposed in the service metadata and will not be accessible to the client.

If all three methods are part of the service contract then all three must have an [OperationContract] attribute - your second example is correct.

0

精彩评论

暂无评论...
验证码 换一张
取 消