views:

40

answers:

1

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 have to do it this way:

[OperationContract]
bool IsHappy(string userID);

[OperationContract]
bool IsSad(string userID);

[OperationContract]
bool IsHungry(string userID);
+2  A: 

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.

Andrew Hare
Much obliged. Thanks a lot! :)
Serg