WCF: why do I have to set [field]specified manually to send value to server?
I generated WCF proxy that has integer [fi开发者_JAVA技巧eldName] in message contract request class. I tried to send value to server but value always came 0 until I manually set [fieldNameSpecified] to true.
Is there something wrong with proxy generation or WCF was designed this way? What are the reasons behind [Specified] fields especially if string/guids have no specified fields in proxy classes?
Thank you in advance
It's because the Xml Serializer was never updated to support Nullable, so the way it dealt with optional fields using value types (say, an int, which can't be set to null) was to have a XxxSpecified boolean field alongside it that allowed you to tell the serializer whether to consider the value for the corresponding field or not during serialization.
精彩评论