N
N
Nikita_Danilov2015-05-24 23:45:58
Computer networks
Nikita_Danilov, 2015-05-24 23:45:58

How to override the namespace of an entire WCF service data contract?

Colleagues, greetings,
An unexpected task was born: It is necessary for a WCF service, either during the build process or during operation, to redefine the namespace of the entire data contract, that is, for all entities used.
The problem is: There are 2 different services with different namespaces, let's call them " ns1 " and " ns2 ". They use in the contract some common entities from the common project that have the namespace "nsBase", as a result, the contract has both the space " ns1 " and " nsBase ".
Thus:
1) In fact, moments of internal implementation emerge, since for the user of the service, the presence of this base namespace does not make any sense.
2) Formed SOAP requests, if you work with them through XML, contain a hodgepodge of prefixes from different namespaces.
I found one terribly crutch way - using IDataContractSurrogate and returning the data type from the GetDataContractType method as a stub, just with the right namespace. But stamping such plugs is also not the best solution, there is always a risk of losing something.
I would like to make the scheme neat, and reuse the code / entities.
I would be grateful if someone could share their ideas on how to solve this problem, thanks!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question