I have my WCF service returning data both in XML and JSON format.
One functios has to return a List, because I don\'t know which class will be used to fill this list
To make it work, your service has to know the types it needs to serialize. If they cannot be found out by looking at your method's signature (for example because one type is object
), you need to list all types that could possibly be in that object
.
Annotate them to the top of your service class, if you list for example can have instances of foo
, bar
and baz
:
[ServiceKnownType(typeof(foo))]
[ServiceKnownType(typeof(bar))]
[ServiceKnownType(typeof(baz))]