tags:

views:

56

answers:

1

In WCF if we use webreference in the client project additional argument called "IsSpecified of bool" is automatically added for each of the argument that written in the Service. Why it was happening?

+1  A: 

This property is added to the proxy class for any types that can be ignored during serialization. It is a notification to the XMLSerializer to ignore that type and not serialize it.

The types that have this property generated for them are the value types - including bool, int and DateTime.

My take on the meaning of this is that value types cannot be null so you need some way of telling the serializer that you want to send nothing.

For a reference type like string you could simple set it equal to null and the serializer would happily take care of the rest. For value types you need to help the serializer out, otherwise it will just have to send the default value of the type.

I'm sure someone else can elaborate more on the techincal reasons for this behaviour but I think what I said is broadly speaking correct.

This post goes into this issue a little.

David Hall