Detecting the same class twice with WCF

I have 2 WCF services that expose the same object. Suppose that the first service (SerA) provides a class (classA) and the second service (SerB), which adds a populated classA, also provides this class (since this class is included in the parameters). Now when I retrieve ClassA from SerA, it merges with the SerA.classA namespace, and when I add it using the second service, this requires a class such as SerB.ClassA. Is there a way to indicate that both classes are the same. I tried changing the namespace in reference.vb and it works, but that would be a real problem when updating the service link. Can someone help me with this? Thanks

+3
source share
2 answers

You can put your definition ClassA(and other data contracts) in the class library and reference it from both services. Thus, both must use the same definition DataContracts.ClassA.

It is always useful to separate your service materials from individual projects:

  • services (maintenance, work, data and, possibly, messaging contracts) into one class library (“Contracts”) - perhaps even several libraries
  • class service implementation
  • service host - if necessary (without using IIS) - into a separate assembly (console application)

This way, you can reuse some parts of your service contracts, and possibly implementations.

squeeze

+2
source

?

, .

, " " service1 wcf-, ClientProject, service1,

ClientProject.Service1_ref.Car

Reference.cs

, reference.cs, , .

, 'add service reference' : http://devx.com/codemag/Article/39837/1763/page/5 - Monsters X 0 edit

0

Source: https://habr.com/ru/post/1720772/


All Articles