这个是要序列化的类
Code
using System;
using System.Collections.Generic;
using RecordManagement;
/// <summary>
/// 用户进行一次记录检索后得到的结果集
/// </summary>
public class RecordRetrieveItem<TRecord>
where TRecord : IRecord<TRecord>
{
#region 成员
private int _totalNum;
private int _retrievedNum;
private List<TRecord> _records;
#endregion
#region 属性
/// <summary>
/// 记录源总数是多少
/// </summary>
public int TotalNum
{
get
{
return _totalNum;
}
}
/// <summary>
/// 当前获取了多少条记录
/// </summary>
public int RetrievedNum
{
get
{
return _retrievedNum;
}
}
/// <summary>
/// 当前获取的记录集
/// </summary>
public List<TRecord> Records
{
get
{
return _records;
}
}
#endregion
#region 构造函数
public RecordRetrieveItem(int totalNum, int retrievedNum, List<TRecord> records)
{
_totalNum = totalNum;
_retrievedNum = retrievedNum;
_records = records;
}
public RecordRetrieveItem()
{
}
#endregion
}
这个是Web服务的代码
Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Script.Services;
/// <summary>
/// Summary description for TestRecordManager
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ScriptService]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class TestRecordManager : System.Web.Services.WebService
{
public TestRecordManager()
{
//Uncomment the following line if using designed components
//InitializeComponent();
}
[WebMethod]
public RecordRetrieveItem<JobRecord> GetRecords(int recordNum,int pageNum)
{
RecordManager manager = new RecordManager ();
List<Record> records = manager.GetAllRecords();
List<Record> result = records.GetRange(pageNum * recordNum, recordNum);
return new RecordRetrieveItem<JobRecord>(records.Count,
result.Count, result);
}
}
而调用该Web服务返回的XML文档中只有记录集的那个List,而TotalNum与RetrievedNum却不见踪影,所以想请教下为什么只序列化了一个字段。