job44927

I have a class that I am passing to a wcf service for example...

[DataContract(Namespace = http://DataContractsNS)]
public class Order
{
private int _OrderID;
private int _VersionID;
[DataMember]
public int OrderID { get { return _OrderID; } set { _OrderID = value; } }

[DataMember]
public int VersionID { get { return _VersionID; } set { _VersionID = value; } }
}

On the client, I do this...

Order o = new Order()
o.OrderID = 1234;
o.VersionID = 1;
client.SentOrder(o);

....
...

On the server, the OrderID and VersionID always comes across as zeros, i.e., OrderID=0 and VersionID=0.
I am stomped and can't figure out why this is happening. The funning thing is that I have other non-numeric fields in this class that comes across fine!



Re: Windows Communication Foundation (Indigo) Problem passing Int datatype field in class to wcf service

Daniel Wu - MSFT

Hi,

To clarify your problem, did you mean that if you have non-numeric fields such as string, it actually arrives to the service correctly, but numerica fields such as int and double are not working

Daniel






Re: Windows Communication Foundation (Indigo) Problem passing Int datatype field in class to wcf service

Zhisheng Huang - MSFT

Could you please post your code I will look into it. Thanks.





Re: Windows Communication Foundation (Indigo) Problem passing Int datatype field in class to wcf service

job

project is too large to post... but when I generated the proxy using svcutil, I noticed that the framework generated additional properties for each non-string fields. For example, if I had a property like...

private int _TotalCount; public TotalCount(get;set;)...

....an additional property called bool TotalCountIsSpecified is generated in the proxy.

So when I set the TotalCount property to a non-zero value, I have to also set the property TotalCountIsSpecified property to true, else, TotalCount property will appear as zero on the server, although I explicitly set it on the client to a non-zero value.

I'm not sure why I had to set the 'IsSpecified' property, but that fixed it.

Can someone explain this





Re: Windows Communication Foundation (Indigo) Problem passing Int datatype field in class to wcf service

Zhisheng Huang - MSFT

Your generated proxy uses XmlSerializer intead of DataContractSerializer. The xxxSpecified is XmlSerizlier feature.

Here is the XmlSerializer doc which has an explanation of the xxxSpecified feature: http://msdn.microsoft.com/library/default.asp url=/library/en-us/cpref/html/frlrfSystemXmlSerializationXmlSerializerClassTopic.asp.

If you search the web with key word "xxxSpecified Xmlserializer", you can also find a bunch of topics on this.