I have a simple class, let’s say “Team” and I expose a WCF service (basicHttpBinding, hosted in IIS) with a GetTeams operation which returns an array of Team.
The Team class looks like
[DataContract]
public class Team
{
[DataMember]
public int Id { get; set; }
[DataMember]
public Point Position { get; set; }
[DataMember]
public string Code { get; set; }
[DataMember]
public bool Available { get; set; }
[DataMember]
public string Extra { get; set; }
[DataMember]
public double X { get; set; }
[DataMember]
public double Y { get; set; }
}
On the client (Silverlight 3.0 app) I get all the data but the Position property holds a default Point instance. The Point struct is System.Windows.Media.Point which is serializable. I also added the X and Y properties to duplicate the Position data to see if it gets right on the other end of the wire.
The XML intercepted (thanks, Firebug!) looks like so:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<GetTeamsResponse xmlns="http://tempuri.org/">
<GetTeamsResult xmlns:a="http://schemas.datacontract.org/2004/07/MyProject.Data" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<a:Team>
<a:Code>A23HJGF23</a:Code>
<a:Available>true</a:Available>
<a:Extra i:nil="true"/>
<a:Id>1</a:Id>
<a:Position xmlns:b="http://schemas.datacontract.org/2004/07/System.Windows">
<b:_x>572194.59937858</b:_x>
<b:_y>322518.3889979</b:_y>
</a:Position>
<a:X>572194.59937858</a:X>
<a:Y>322518.3889979</a:Y>
</a:Team>
<!-- other <a:Team> elements -->
</GetTeamsResult>
</GetTeamsResponse>
</s:Body>
</s:Envelope>
Therefore it seems there is a deserialization issue. No exception is thrown!
Why?
Just as a quick clarification, is your WCF service returning the .net 3 / 3.5 point class whilst the SL is attempting to use the SL point class? Or are they both referring to the same point structure.
I’m thinking you are passing the .Net version to the SL version because that namespace in the position datacontract seems to indicate your using the CLR / WPF point, which is not the same as the SL point.
The WCF endpoint will use the ISerializable to change to the XMLSerializer instead of the data contract serializer, so you will see the data, but as a custom class with the _x and _y you see in the XML at present.
Edit:
For clarity over the struct location
SL3 Point Struct is in System.Windows.DLL (http://msdn.microsoft.com/en-us/library/system.windows.point(VS.95).aspx)
.Net 3.0 Point Struct is in windowsbase.dll (http://msdn.microsoft.com/en-us/library/system.windows.point(VS.85).aspx)
.Net 3.5 Point Struct in WindowsBase.dll (http://msdn.microsoft.com/en-us/library/system.windows.point.aspx)
Same name, not the same class however when comparing the .net to the SL.
And a bit of an addition, it occuring in SL 2.0 and being reported on the SL website. (http://silverlight.net/forums/t/26577.aspx)