Make WCF services to help use the same namespace when called from WCF Clients

We have two services, that can be called independently, but also can be used together. They have some common types, and if they called together, default Visual Studio proxy generation will create the same types in different namespaces.
There are multiple articles, that recommend to use command line SvcUtil instead of Visual Studio IDE.
The article How to reuse types across service endpoints suggests on client side manually update Reference.svcmap to include multiple <MetadataSources> and NamespaceMappings
Alternatively svcutil does allow you to specify multiple endpoints at a single time and utilize /r(/reference)  and /n(/namespace) parameters
.Another commonly discussing solution is to  Share Types Between WCF Service and Client., but client not always has access to served data types.

If you are writing services and wish to simplify coding by your clients, consider to create additional “wrapper” service, that will include implementations of both interfaces, that are implemented by original services.
The approach is mentioned in  Generating Proxy class file for webservices with sharing TYPES and Meineck.Net: WCF: Hosting multiple WCF services as one single service.
Note that wrapper service will describe methods from both services, but the actual methods are trivial- just redirect to individual services implementation.

Advertisements