开发者

WCF Operation contract availability

开发者 https://www.devze.com 2022-12-25 06:14 出处:网络
This question was asked at interview. Say I have a contract. [ServiceContract] public interface IMyService

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.

0

精彩评论

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