Re: [Mono-dev] WCF Error Deserializing SOAP Reply

2011-10-27 Thread Marc Bettex
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


[Mono-dev] WCF Error Deserializing SOAP Reply

2011-08-27 Thread blaynebayer
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) 

I have tried adding the web reference both in visual studio and in
MonoDevelop with the same results. 

I am using the latest version of Mono (2.10.4) 

Has anyone seen this before? I have been banging my head against the wall
for hours on this one and haven't got a clue. 

Thanks in advance

--
View this message in context: 
http://mono.1490590.n4.nabble.com/WCF-Error-Deserializing-SOAP-Reply-tp3770895p3770895.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


Re: [Mono-dev] WCF Error Deserializing SOAP Reply

2011-08-27 Thread Atsushi Eno
Hello,

Without code, we cannot give any thoughts.

Atsushi Eno

On 2011/08/26 6:49, 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)

 I have tried adding the web reference both in visual studio and in
 MonoDevelop with the same results.

 I am using the latest version of Mono (2.10.4)

 Has anyone seen this before? I have been banging my head against the wall
 for hours on this one and haven't got a clue.

 Thanks in advance

 --
 View this message in context: 
 http://mono.1490590.n4.nabble.com/WCF-Error-Deserializing-SOAP-Reply-tp3770895p3770895.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




___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list