views:

38

answers:

1

Hi,

I have a 2 WCF services that are exposing the same object. Lets say the first service (SerA) exposes a class (classA) and the second service (SerB) which adds the filled classA also exposes this class (as this class is included in the parameters) Now when I retrieve the classA from SerA, it is concatenated with a namespace SerA.classA and when I add this using the second service, it requires a class like SerB.ClassA. Is there a way to specify that both classes are the same. I tried changing the namespace in reference.vb and it works but it would be real problem when the service reference is updated. Can anyone help me out in this? Thanks

+1  A: 

You can put your ClassA (and other data contracts) definition into a class library and reference it from both services. That way, both should be using the same DataContracts.ClassA definition.

It's always a good idea to separate your service stuff into separate projects:

  • the services (service, operation, data and possibly message contracts) into one class library ("Contracts") - possibly even into multiple libraries
  • the service implementation(s) into a class library
  • the service host(s) - if needed (not using IIS) - into a separate assembly (console app)

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

MArc

marc_s
That does not work Marc. I already have my classes in another class library. I only have the contracts in the same project as the wcf service and they are just exposing the classes from the class library. But this is still giving me the same error!
Farax
Not 100% sure what you're saying: are the DataContracts in the common class library, or in each of the service projects? The DataContracts themselves must be in the shared, common library - otherwise this will never work.
marc_s