Question

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

Was it helpful?

Solution

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

OTHER TIPS

NO answer to this eh?

The problem is the service reference generates its own class definition..

eg, i have a class "car" in a common library, and service1 wcf service which i'm using from ClientProject but when i add a reference to service1, you get

ClientProject.Service1_ref.Car

created within Reference.cs

Right now i'm having to fix this by modifying the reference.cs to use the common classes each time, really not good.

edit: This guy has the answer, don't use 'add service reference' its easy to do it elsewise: http://devx.com/codemag/Article/39837/1763/page/5 – Monsters X 0 secs ago edit

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top