How to specify default values in WCF web services

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dave Burns

    #1

    How to specify default values in WCF web services

    Hello,

    I am trying to specify a logical default value for a [DataMember] in a WCF
    Web Service using basicHttpBindin g.

    I realize that the language defaults are:

    int - 0
    string - null
    bool - false
    enum - ?

    I tried using OnDeserializing and OnDeserialized events, but when the client
    doesn't explicitely set the value for an int member, for instance, I keep
    getting 0. For a bool memeber I get a 'false', and for an enum member it
    picks some default, but I don't know how it picks it. The only default that
    I can logically work with is the null for reference types, including
    strings.

    The XSD allows you to specify "default=" attribute for a member, but in WCF
    I don't have control over wsdl/schema generation. So I thought there would
    be a way to specify a logical default value for a DataMember through an
    Attribute settings of some sort, but I can't find one.

    Please help!!!

    thanks, Dave


Working...