WebService 设计总结
转载:http://blog.csdn.net/fangxing80/article/details/26940845
原始的 WebService 如下:
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Services;
- using WebService1.Entity;
- using WebService1.Service;
- using System.Web.Services.Protocols;
- namespace WebService1
- {
- [WebService(Namespace = "http://tempuri.org/")]
- [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
- [System.ComponentModel.ToolboxItem(false)]
- public class Service1 : System.Web.Services.WebService
- {
- [WebMethod]
- public PageResult<Order> QueryOrder(Query<OrderCondition> queryInfo)
- {
- OrderService service = new OrderService();
- return service.Query(queryInfo);
- }
- }
- }
PageResult<T>, Query<T> 将统一的业务部分抽取出来,这样定义其他的业务对象就能简化了。
- using System;
- using System.Collections.Generic;
- namespace WebService1.Entity
- {
- [Serializable]
- public class PageResult<T>
- {
- public int PageNo { get; set; }
- public int PageSize { get; set; }
- public int TotalCount { get; set; }
- public int PageCount { get; set; }
- public bool HasNextPage { get; set; }
- public List<T> Data { get; set; }
- }
- }
- using System;
- using System.Collections.Generic;
- namespace WebService1.Entity
- {
- [Serializable]
- public class Query<T>
- {
- public int PageNo { get; set; }
- public int PageSize { get; set; }
- public T Condition { get; set; }
- }
- }
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。