Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WCF Serialised List object giving strange names for objects

Here is the Method signature in the WCF service:

APIMessageList<APISimpleContact> GetMembers(string apiKey, APIContactSearchFilter filter);


APIMessageList inherits from IList. Once I have built a proxy against this WCF service the class name is APIMessageListOfAPISimpleContactjHldnYZV.

Why do I not get: APIMessageListOfAPISimpleContact?

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?

Many thanks
Joe

like image 821
Joe Pinder Avatar asked Aug 03 '11 14:08

Joe Pinder


Video Answer


1 Answers

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> { ... }
like image 116
carlosfigueira Avatar answered Nov 15 '22 08:11

carlosfigueira