写了一个webservice 的一个方法,该方法返回了一个list<PacsFeildsInfo>,PacsFeildsInfo 是一个可以序列化的类,里面有对应的包含get(),set()方法的属性。
客户端远程调用这个方法的时候list<PacsFeildsInfo> 结构接收到了,但是PacsFeildsInfo 里面的属性值都为null。各位大神帮忙看一下,为什么会这样。谢谢!

解决方案 »

  1.   

    set的时候 是不是被清空了
      

  2.   

    既然可以序列化,为什么不用json来做
      

  3.   

    没有,我在调试的时候,list里都有值,发布到服务器,客户端调用就都为null 了..
    是不是webservice不支持返回值为list的?
      

  4.   

    客户端是winform。。
      

  5.   

    get;set 属性是public 还是private?
      

  6.   

    public
      

  7.   

    http://www.cnblogs.com/teacherz/archive/2010/10/19/2353826.html
    http://blog.sina.com.cn/s/blog_64008ed70101bwib.html
    http://blog.csdn.net/limlimlim/article/details/8651043
      

  8.   

    http://www.cnblogs.com/yinhaiming/articles/1379424.html
    http://blog.sina.com.cn/s/blog_4ddb9c440100a78p.html参考吧
      

  9.   

    参考了,都不行。实体类里的属性值还是null无语了
      

  10.   

    参考了,都不行。实体类里的属性值还是null无语了
      

  11.   

    参考了,都不行。实体类里的属性值还是null无语了
      

  12.   

    [DataContract][DataMember]
      

  13.   

    [DataContract][DataMember]
      

  14.   

    在接口方法处声明序列化
    如:
     [WebMethod(Description = "测试用例")]
        [XmlInclude(typeof(DeptModel))]
        public List<DeptModel> WS_SFK_TESTEXP(int num)
        {
            List<DeptModel> res = new List<DeptModel>();
            DeptModel deptModel = null;
            for (int i = 0; i < num; i++)
            {
                deptModel = new DeptModel();
                deptModel.DeptID = i + 1;
                deptModel.EmployeeLM = new List<EmployeeModel>();            EmployeeModel employeeModel = null;
                employeeModel = new EmployeeModel();
                employeeModel.EmployeeID = 10000 + i + 1;
                List<string> name = new List<string>();
                name = GenerateChineseWords(3);
                employeeModel.EmployeeName = name[0] + name[1] + name[2];
                employeeModel.EmployeeTime = DateTime.UtcNow;
                deptModel.EmployeeLM.Add(employeeModel);            employeeModel = new EmployeeModel();
                employeeModel.EmployeeID = 10000 - i - 1;
                List<string> name2 = new List<string>();
                name2 = GenerateChineseWords(3);
                employeeModel.EmployeeName = name2[0] + name2[1] + name2[2];
                employeeModel.EmployeeTime = DateTime.Now;
                deptModel.EmployeeLM.Add(employeeModel);            res.Add(deptModel);
            }
            
            return res;
        }同时,类的实体声名为可序列化的类 
        [Serializable]
        public class DeptModel
        {
            private int deptID;        public int DeptID
            {
                get { return deptID; }
                set { deptID = value; }
            }
            private List<EmployeeModel> employeeLM;        public List<EmployeeModel> EmployeeLM
            {
                get { return employeeLM; }
                set { employeeLM = value; }
            }    }调试过程:
    得到结果: