i have wcf service has 3 methods, list of items, add items, , single item.
there 4 possible types inherited base class. service decorated serviceknowntype each of derived classes.
when consume service , don't choose re-use assemblies , reference pocos getlist works expected. when re-use assemblies list throws serialization exception.
looking @ reference.cs file generated wcf client can see knowntypeattribute created on base class that's been generated. on project re-use base classes decorates methods serviceknowntypeattribute instead.
so on invoking web method return list following... the deserializer has no knowledge of type maps name. consider using datacontractresolver or add type corresponding 'thechildobject' list of known types - example, using knowntypeattribute attribute or adding list of known types passed datacontractserializer.
is there work around problem? must quite common?
i add such line above relevant interfaces
[serviceknowntype("getknowntypes", typeof(knowntypeshelper))]
and implementation of
public static class knowntypeshelper { /// <summary> /// lists wcf known types /// </summary> /// <param name="provider"></param> /// <returns>a collection of wcf known types</returns> public static ienumerable<type> getknowntypes(icustomattributeprovider provider) { system.collections.generic.list<system.type> knowntypes = new system.collections.generic.list<system.type>(); knowntypes.add(typeof(wrntycommon.wrntydbenums)); // add types include here. knowntypes.add(typeof(aaa)); knowntypes.add(typeof(bbb)); knowntypes.add(typeof(ccc)); return knowntypes; } }
Comments
Post a Comment