We have an interesting issue when passing a csla based object as a parameter to a WCF call ([OperationContract]). I am not very familiar with WCF, so forgive any ignorance I might show using WCF terminology. I am the author of the csla business objects and another developer is the author of the WCF code. The gory details... We are using Csla 3.8.2 and the Business objects are using managed backing fields and when passed as a parameter to a WCF Operation Contract, we get the following exception:
There was an error while trying to serialize parameter http://tempuri.org/:stat. The InnerException message was Type 'Csla.Core.FieldManager.FieldData`1[[System.String, mscorlib, Version=188.8.131.52, Culture=neutral, PublicKeyToken=b77a5c561934e089]]' with data contract name 'FieldDataOfstring:http://schemas.datacontract.org/2004/07/Csla.Core.FieldManager' is not expected. Add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.
If we change the business object to use private backing fields, the object flows flawlessly across WCF. While I have no problem changing our business object to use private backing fields for non-child properties, most of our business objects contain at least one Child reference property. I also want to be consistent in that all our business objects use the same backing mechanism. Has anyone else run into this situation and is there a work around? Do later versions of Csla possibly address this? Any ideas?
Csla objects are not designed to be directly input or output of a web service. Instead your web service should be exposing DTOs, which your service maps into and out of Csla based objects.
See this page for more information: http://www.lhotka.net/cslanet/faq/XmlServicesFaq.ashx
Thanks much for the info Andy, That is pretty much what I suspected, and just wanted conformation from some folks who have more expreience using this framework.
Copyright (c) Marimer LLC