Wednesday, 12 January 2011

WCF Returning object arrays

When an array of object is used as the return type or is embedded as part of a parent type in a WCF webservice the object types appearing in the object array should be listed in the ServiceKnownTypeAttribute

[OperationContract]

[ServiceKnownType(typeof(ParameterType))]
[ServiceKnownType(typeof(ConnectorTypeSlot))]
DeviceDescription GetDeviceDescription(int revisionId, int feId);
 
In the case above the DeviceDescription type has an object[] defined in its object tree and the ParameterType appears as a possible object in that object[].