验证WCF数据合同

时间:2016-02-20 10:38:38

标签: wcf data-annotations

我需要验证来自请求的数据。到目前为止我所做的是:

  1. 添加了对DevTrends.WCFDataAnnotationsSystem.ComponentModel.DataAnnotations

  2. 的引用
  3. 在服务实现中放置 [ValidateDataAnnotationsBehavior]

  4. 在数据上放置属性,如:
                                                                          private int items=0;
    [DataMember] [Range(0, 6, ErrorMessage = "Items must be an integer between 0 and 6")]

    public int Items
    {
        get { return items; }
        set { items = value; }
    }
    

    根据http://wcfdataannotations.codeplex.com/,这就是所需要的。我错过了什么?当我发送SoapUI请求时,它显示'格式化程序在尝试反序列化消息时抛出了异常“

0 个答案:

没有答案
相关问题