WCF 序列化列表对象为对象提供奇怪的名称 [英] WCF Serialised List object giving strange names for objects
问题描述
以下是 WCF 服务中的方法签名:
Here is the Method signature in the WCF service:
APIMessageList<APISimpleContact> GetMembers(string apiKey, APIContactSearchFilter filter);
APIMessageList
继承自 IList
.一旦我针对这个 WCF 服务构建了一个代理,类名就是 APIMessageListOfAPISimpleContactjHldnYZV.
APIMessageList
inherits from IList
. Once I have built a proxy against this WCF service the class name is APIMessageListOfAPISimpleContactjHldnYZV.
为什么我没有得到:APIMessageListOfAPISimpleContact?
Why do I not get: APIMessageListOfAPISimpleContact?
它在接口中每个 APIMessageList 对象的末尾添加随机文本(有几个)它们都以相同的几个字符结尾 - jHldnYZV.我在网上寻找可能的原因,但我找不到任何有此问题的人的帖子.
It adds random text to the end of every APIMessageList object in the interface (there are several) They all end with the same few chars - jHldnYZV. I have looked online for possible causes, but I can't find any posts of people having this problem.
这纯粹是一个表面问题,但此界面会暴露给我们的外部客户,因此其外观很重要.
This is a purely cosmetic issue but this interface is exposed to our external customers so its appearance is important.
有人知道我为什么会遇到这个问题吗?
Anybody know why I am getting this problem?
非常感谢
乔
推荐答案
您的解决方案将位于 http://msdn.microsoft.com/en-us/library/ms731045.aspx.基本上,由于您可以有多个SimpleContract"类(在不同的命名空间中),WCF 将在合同名称的末尾添加一个消歧哈希,这就是您在合同名称末尾的 8 个字符中所拥有的.但是您可以通过使用 CollectionDataContract 及其 Name 属性来控制它:
Your solution will be at http://msdn.microsoft.com/en-us/library/ms731045.aspx. Basically, since you could have multiple "SimpleContract" classes (in different namespaces), WCF will add a disambiguation hash to the end of the contract name, which is what you have in the 8 chars at the end of the contract name. But you can control that, by using the CollectionDataContract and its Name property:
[CollectionDataContract(Name = "APIMessageListOfSimpleContract")]
public class APIMessageList : IList<SimpleContract> { ... }
这篇关于WCF 序列化列表对象为对象提供奇怪的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!