[收藏转贴]构建RESTful风格的WCF服务
RESTful Wcf是一种基于Http协议的服务架构风格。 相较 WCF、WebService 使用 SOAP、WSDL、WS-* 而言,几乎所有的语言和网络平台都支持 HTTP 请求。 RESTful的几点好处: 1、简单的数据通讯方式,基于HTTP协议。避免了使用复杂的数据通讯方式。 2、避免了复杂的客户端代理。 3、直接通过URI资源定向即可把服务暴露给调用者。 下面使用一个简单的demo项目来看看啥是RESTful Wcf。 1、项目结构【VS2010+.net 4.0】: 2、接口定义:定义了2个方法,分别代表GET、POST典型请求方式。 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.ServiceModel; 6 using System.ServiceModel.Web; 7 using MyWcfService.Model; 8 namespace MyWcfService 9 { 10 [ServiceContract(Namespace = ServiceEnvironment.ServiceNamespace, Name = "user")] 11 public interface