Question

I am really confused about one scenario in WCF.

I have on WCF service " SERVICE1" which exposes two operations "OP1" and "OP2".

There are two clients consuming the service "CLIENT1" AND "CLIENT2".

The condition is "CLIENT1" can only invoke "OP1" while "CLIENT2" is restricted to "OP2".

Was it helpful?

Solution

Refactor your service contracts to exposes two endpoints, the interface of which is only relevant to the client that is consuming it:

   [ServiceContract]
    public interface IService1
    {
        [OperationContract]
        void OperationOne();
    }

    [ServiceContract]
    public interface IService2
    {
        [OperationContract]
        void OperationTwo();
    }

    public class MyServcie: IService1, IService2
    {
        //Implementation here...
    }

This way the client of IService1 doesn't even know that the methods on IService2 exist.

This is not restricted to WCF - this is good practice in OOP too....

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top