Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing Null Parameters to a WCF Service

Tags:

.net

null

wcf

I am curious about the way a non-.NET client application of a WCF service can signal to a given method that it doesn't want to specify a value for a given parameter (making the service then assuming a default value). In other words, how can an application signal a null parameter to a WCF service?

like image 238
B.M Avatar asked Jan 20 '23 12:01

B.M


1 Answers

It can exclude the parameter from the SOAP document (assuming HTTP endpoint), assuming this is allowed.

Exactly if this is allowed/how this should be done depends on how the XSD is generated.

These can be controlled by the arguments to the [DataMember] attribute.

If [DataMember(IsRequired=true)] MSDN then the xml will be required to contain this element (minOccurs will be 1 I believe), and if the element may be nillable (nillable=true, depending on datatype)

If [DataMember(EmitDefaultValue=true)] MSDN then there will be an element if the element has its default value when the item is serialized.

like image 123
Sam Holder Avatar answered Jan 25 '23 10:01

Sam Holder