Web link in WCF

In WCF, if we use a web reference in a client project, an additional argument called "IsSpecified of bool" is automatically added for every argument written in the Service. Why did this happen?

0


source to share


1 answer


This property is added to the proxy class for any types that can be ignored during serialization. This is a notice XMLSerializer

to ignore this type and not serialize it.

The types for which this property is created are value types — including bool

, int

and DateTime

.

My point is that value types cannot be null, so you need to tell the serializer in some way that you don't want to send anything.



For a reference type of type, string

you can simply set it to zero and the serializer will happily take care of the rest. For value types, you need to help infer the serializer, otherwise it will just need to send the default of that type.

I'm sure someone else will be able to elaborate on the technical reasons for this behavior in more detail, but I think what I said is generally correct.

This post is slightly related to this issue.

+1


source







All Articles