WCF和多个名称空间的问题-跨多个服务引用共享对象类型 [英] Problem with WCF and multiple namespaces - sharing object types across multiple service references

查看:78
本文介绍了WCF和多个名称空间的问题-跨多个服务引用共享对象类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个Web服务.一种具有用户功能,一种具有管理员功能.

i have two web services. One with user functionality, one with admin functionality.

两个服务都可以有效地使用相同的对象类型,例如:

Both services effectively work with the same object types, for instance:

  • AdminService提供用于删除/修改客户对象的功能
  • UserService提供用于列出/读取客户对象的功能

现在在客户端中,我有两个服务引用,即Webservices.Admin和Webservices.User.

Now in the client i have two service references, Webservices.Admin and Webservices.User.

如果我使用UserService检索客户对象,则无法通过AdminService操作那些对象,因为UserService检索类型为Webservices.User.Customer的对象,但是AdminService可以与类型为Webservices.Admin.Customer的对象一起使用.

If i use the UserService to retrieve Customer objects, i cannot manipulate those via the AdminService, since the UserService retrieves objects of type Webservices.User.Customer, however the AdminService works with objects of type Webservices.Admin.Customer.

在服务器端,这两种类型是相同的,只是属于客户端中的不同名称空间.

On the server side both types are identical, just belong to different namespaces in the client.

现在的问题是:如何在不同的服务引用之间共享类型?

推荐答案

查看 http://cgeers.com/2011/07/31/wcf-sharing-types-using-svcmap/ 通过调整Reference.svcmap文件,可以确保为不同服务引用使用的每个DataContract只生成一个类.

Check out http://cgeers.com/2011/07/31/wcf-sharing-types-using-svcmap/ By tweaking the Reference.svcmap file you can make sure only one class is generated for each DataContract used by the different service references.

注意:请记住在按更新服务参考"之前删除节点的内容

Note: Remember to delete the content of the node before pressing 'Update Service Reference'

这篇关于WCF和多个名称空间的问题-跨多个服务引用共享对象类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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