I have an MVC project in .Net 4 with WCF service with BasicHttpBinding.
When consuming this service in .Net 2 the values that arriving if the property is int are 0.
if it is a string, than it goes fine.
bulding a new project in .Net 4 consuming the same service and using the exact implementation (as the .Net 2) ==> the int values are correct.
WHY?
Thanks!
I bet you have a data contract that has the actual int
property:
public int YourProperty ......
as well as a YourPropertySpecified
property along side it:
public bool YourPropertySpecified ......
Since an int
cannot be null, WCF cannot distinguish whether or not you have defined a value - you need to tell it.
So if you use an int
property and set a value to it - you also need to set its accompanying YourPropertySpecified
property to true:
yourData.YourProperty = 42;
yourData.YourPropertySpecified = true;
With this extra step, the int
values should arrive at the server just fine
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With