多个WCF服务引用相同的数据协定 [英] Multiple WCF services referencing the same data contracts

查看:85
本文介绍了多个WCF服务引用相同的数据协定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一组共享通用数据合约(或您愿意的实体)的WCF服务.这些是简单的数据传输对象,装饰有DataContract和DataMember属性.我明确指定了名称和名称空间.为了遵循IDesign的建议(每个服务合同平均12个成员)的建议,我将服务项目分解为多个服务.

I am building a set of WCF services that share common data contracts (or entities if you prefer). These are simple data transfer objects that are decorated with DataContract and DataMember attributes. I am explicitly specifying the name and namespace. In trying to follow the principles of IDesign's recommendation of averaging 12 members per service contract, I am breaking my service project into multiple services.

我的数据合同在单独的程序集中,如果他们使用.Net,我可以将其提供给我们的客户.他们可以告知其服务引用以引用的程序集中的重用类型.但是,如果他们没有使用.net,并且使用了两个都使用相同实体的服务,那么我认为它们将获得模糊的参考消息.如果不引用数据协定dll,我可以在Visual Studio中看到它.

My data contracts are in a separate assembly that I can provide to our clients if they are using .Net. They can tell their service reference to reuse types in referenced assemblies. However, if they are not using .net and they use 2 services that both use the same entity then they will, I assume, get an ambiguous reference message. I can see this in Visual Studio if I don't reference the data contract dll.

我的问题是,我可以在服务中做任何事情,还是可以在客户端应用程序中做事,以免不得不限定数据合同来自哪个代理?

My question is, is there anything I can do in my services, or they can do in a client app to get around having to qualify which proxy the data contract came from?

推荐答案

很好的文章,介绍了如何解决此问题.

Nice article that describes how to solve this issue. Sharing DataContracts between WCF Services

这篇关于多个WCF服务引用相同的数据协定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆