views:

46

answers:

2

Hi all,

I have a collection of WCF web services that share a common DTO model.

The problem is that when I add service references in Visual Studio 2010, the proxy generated for each of the web services has its own namespace (internal to the solution), meaning that I essentially have duplicate DTO's on each of the service references.

Is there a clean way to get over this and to share the dto, short of creating a facade over the whole group of services?

Cheers.

+1  A: 

You should have the DTO in a seperate library. Add a reference to that library in your client project. And you can configure the proxy generation to used object from referenced library. Right click on your service reference and select configure Service reference there should be an option for Reuse types in referenced assemblies.

pdiddy
+3  A: 

Instead of creating your client proxies via the Visual Studio "Add Service Reference" functionality, you could generate them using Visual Studio's command line tool svcutil.exe. Pass in the URL to the metadata for each service and svcutil should figure out what types they have in common.

http://stackoverflow.com/questions/209224/net-consuming-web-service-identical-types-in-two-different-services/211851#211851

I'm not sure if there is an easier / better way.

Dr. Wily's Apprentice
+1, I have also used this route in past (in VS 2005 era).
VinayC
Agreed, this is the best approach. You could even build this into your automated build process...
Simon Lee
Works a treat. Also, as Simon Lee commented, adding an automated build step to auto generate. Cheers guys.
Oriacle