Hi, I am porting a windows application using wcf running on .Net so that it can run on Mono (2.10.6) and I have bumped in the same problem.
For the context, I use message contracts with the xml serializer and the c# code for the objects is generated by the svcutil.exe program from microsoft (from a wsdl and xsd files given by a third party). I have found that the problem occurs when the XmlSerializer must deserialize the xml for properties that can target more that one type. For instance a property such as this one have this problem. [System.Xml.Serialization.XmlElementAttribute ("WeeklyHours", typeof (decimal), Order=0)] [System.Xml.Serialization.XmlElementAttribute ("WeeklyLessons", typeof (string), DataType="integer", Order=0)] public object Item { get { return this.itemField; } set { this.itemField = value; } } All these properties match an <xs:choice> item in the xsd file. For instance, this property up there matches the following statement. <xs:choice> <xs:element name="WeeklyHours" type="tns:WeeklyHoursType" /> <xs:element name="WeeklyLessons" type="tns:WeeklyLessonsType" /> </xs:choice> I don't know if this problem is a bug in Mono or something that is not supposed to be supported. Anyway, I think that there is a work around this. In my case, I replaced the c# code above by the following one. There is one new property for each possible element in the old property and there is also an xxxSpecified property which is required because of the nullable decimal type (this is the supported way in .Net to have a nullable value type in this case). [System.Xml.Serialization.XmlElementAttribute ("WeeklyHours")] public decimal? WeeklyHours { get { return this.weeklyHoursField; } set { this.weeklyHoursField = value; } } [System.Xml.Serialization.XmlIgnoreAttribute ()] public bool WeeklyHoursSpecified { get { return this.WeeklyHours.HasValue; } set { } } [System.Xml.Serialization.XmlElementAttribute ("WeeklyLessons", DataType="integer")] public string WeeklyLessons { get { return this.weeklyLessonsField; } set { this.weeklyLessonsField = value; } } Of course this is not perfect but it looks like it can work. You need to be strict and make sure that on any given object, you use at most one of the property, otherwise the xsd schema won't be respected. I need to to more testing on this to ensure that it works but I can't for now because after having "solved" that problem, I bumped in the next one :-p Any feedback on this problem/workaround would be welcome. blaynebayer wrote: > > I get the following error when performing a wcf client request to a third > party web service using soap: > > Read by order only possible for encoded/bare format : at > System.Xml.Serialization.ClassMap.GetElement (Int32 index) > -- View this message in context: http://mono.1490590.n4.nabble.com/WCF-Error-Deserializing-SOAP-Reply-tp3770895p3944097.html Sent from the Mono - Dev mailing list archive at Nabble.com. _______________________________________________ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list