views:

201

answers:

1

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  AnothermethodForClientB();
}

When a clientA access the contract it should only see the operation contracts

void methodForClientA(),void  AnothermethodForClientA().

Is it possible in WCF ?

+2  A: 

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.

Randolpho