My application has 2 "services", let's say that this is a basic (integer) calculator, and one is a floating point calculator. I express them as interfaces:
public interface IBasicCalculator { int Add( int a, int b ); } public interface IFloatingPointCalculator { double Add( double a, double b ); }
I want to expose them through WCF. Unfortunately, WCF seems to be very closely connected with the notion that every possible operation that you want to open must go through one service interface - you cannot exchange sessions between services, this is cumbersome on the client side, since you need to create a separate proxy -server for each of them, it seems, there are no "sub-services", etc.
So, I realized that I need to introduce a “combined” interface (you can also call it a facade), for example:
[ServiceContract] public interface ICalculatorService : IBasicCalculator, IFloatingPointCalculator { [OperationContract(Name = "AddInt")] new int Add( int a, int b ); [OperationContract(Name = "AddDouble")] new double Add( double a, double b ); }
If I do this, WCF provides the client with both methods that can call them, and it all really works.
However, "interface inheritance" seems to be inconvenient. In particular, new int Add and new double Add . Strictly speaking, new by the method indicates hiding the base method, which I do not do at all. I can omit new , but then I just get compiler warnings that make up "I think I'm hiding this method, you need to rename it or put" new "on it.
So this is a two-part question:
Am I in the know with my “combine all into one interface” logic, or is there a way to open “sub-services” or “several related services” using WCF?
If this is what needs to be done, is there a better way?
Thanks!
Orion edwards
source share