tags:

views:

384

answers:

2

I am trying to do some contract first development, and have already designed a schema where an element has minoccurs=0 and nullable=false. However I am not able to make a DataContract or XmlSerializer that generates this xsd.

I have an idea that this is not possible.

The only solution I have found is an ugly one: http://www.theserverside.net/tt/articles/content/DesignServiceContracts/DesignServiceContracts.html

In this solution i have to implement the IXmlSerializable and do the shema and the serialization myself. So I would have to maintin both the schema and the C# class -> Ugly

Has anyone found a solution to this or heard from Microsoft that this is not possible?

A: 

Just a thought... is it the same thing if you use MessageContract instead?

sebastian
As far as I know, the messageContract is for messing with the SOAP Envelope - not the XSD.Have you got any idea about how you would use the Messagecontract?
khebbie
A: 

As far as I know, both XmlSerialiser and DataContractSerializer will generate object that will respect the schema if the object is filled correctly, but if the required values are not filled, the produced xml will not validate agains the schema.

You could try to use XsdObjectGenerator.

Philippe