Generating NHibernate WCF Contracts

Feb 18, 2010 at 4:50 PM

Hi,

I just published some code for generating WCF-Data contracts that can be filled directly with NHibernate. For XSD2Code project this could be easily supported with adding the type System.Collections.Generic.IList<T> to list of possible collection type.

With current XSD2Code WCF generation I see 2 issues:

1.) It does not generate the KnownType attribute on base classes. This can lead to nasty serialization problems that result  in "connection forcibly closed by the remote host" errors. You have to use WCF trace facility to detect it.

2.) It implements directly List<T> on collection properties and decorates them with the [XmlArrayItemAttribute] attribute. This doesn't work for WCF as this is a XML-Serializer attribute. To implement this correctly you would have create a class derived from List<T> and then decorate this class with [CollectionDataContractAttribute]. In reality this has very little effect. All serialization will work, only the serialized XML may not be valid against the schema. See my comments here for more details on the issue.

Cheers,

Tobias

Feb 21, 2010 at 2:49 PM
Edited Feb 21, 2010 at 2:52 PM

Hello Tobias:

Could you pull the latest source of Xsd2Code (from source control) and apply your changes and create a Patch?  I'll look at adding it to the base of Xsd2Code. Depending on the Depth of Change I'll get it into this next release or next beta.  Generic IList looks like a good Idea.

 

Feb 26, 2010 at 10:35 AM

I created a patch against build 54914