This question was asked at interview. Say I have a contract.
[ServiceContract]
public interface IMyService
{
[OperationContract]
void methodForClientA();
[OperationContract]
void AnothermethodForClientA();
[OperationContract]
void methodForClientB();
[OperationContract]
void An开发者_C百科othermethodForClientB();
}
When a clientA access the contract it should only see the operation contracts
void methodForClientA(),void AnothermethodForClientA().
Is it possible in WCF ?
You cannot keep client A and client B from seeing each other's methods, because they're all defined in the same contract.
You can, however, keep Client A and Client B from calling each other's methods, using WCF's security mechanisms.
Alternatively, you could have two separate services, each unique to the client.
Edit
The more I think about it, the more I would prefer the separate services options for such a scenario. If you have methods specific to each client, you really have separate services anyway, each specific to the particular client.
精彩评论