开发者

Common DTOs across multiple web services in VS2010

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 namespa开发者_开发知识库ce (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.


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.

.Net Consuming Web Service: Identical types in two different services

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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜