none
Invalid enum value '' cannot be deserialized into type RRS feed

  • Question

  • Hello there,

    I have a WCF service having an enum defined as -

        public enum Operator
        { 
            Equals,
            NotEquals,
            GreatherThan,
            LessThan
        }
    

    DataContract declared as -

        [DataContract]
        public class PropertyQuery
        {
            [DataMember]
            public string PropertyName { get; set; }
    
            [DataMember]
            public Operator Operator { get; set; }        
    
            [DataMember]
            public string PropertyValue { get; set; }
        }

    OperationContract declared as -

        [OperationContract]        
        string GetClientData(string clientName, [Optional] PropertyQuery propertyQuery);   


    However when I send request for 'GetClientData()' using SoapUI with passing value only for first parameter 'clientName' and leaving blanks for 'propertyQuery' parameters - 

          <tem:GetClientData>
             <tem:clientName>AV</tem:clientName>
             <!--Optional:-->
             <tem:propertyQuery>
                <!--Optional:-->
                <wcf:Operator></wcf:Operator>
                <!--Optional:-->
                <wcf:PropertyName></wcf:PropertyName>
                <!--Optional:-->
                <wcf:PropertyValue></wcf:PropertyValue>
             </tem:propertyQuery>
          </tem:GetClientData>

    I get following message - 

    Invalid enum value '' cannot be deserialized into type 'WCFService2.Operator'. Ensure that the necessary enum values are present and are marked with EnumMemberAttribute attribute if the type has DataContractAttribute attribute.  

    I know this error makes sense.   
    But how to make 'propertyQuery' as optional and thus 'Operator' as optional and get rid of this error.

    Please guide.






     
    Sunday, January 18, 2015 10:29 PM

Answers