Restfull分格的 WCF服务简单构建流程
1为项目添加WCF Service.svc
2修订web.config
<system.serviceModel>
<standardEndpoints>
<webHttpEndpoints>
<standardEndpoint name="" helpEnabled="true" automaSelectionenabled="true"/>
</webHttpEndpoints>
</standardEndpoints>
<serviceHostingEnvironment aspNetcompatiblityEnabled="true" multipleSiteBindingsEnabled="true"/>
3 修订Service.svc标记语法
Factory="System.serviceModel.Activation.WebServiceHostFactory"
4 [无需接口抽象]
5 增补Service.svc.cs 属性
[servicecontract]
[ServiceBehavior(InstanceContextMode=InstanceContextModel.Single,ConcurrenceyMode=ConcurrencyModel.Single)]
[AspNetCompatiblilityRequirements(RequriementsMode=AspNetCompatiblilityRequirementsMode.Required)]
6 为服务方法增补属性
[Operation/contract,WebInvoke(UriTemplate="some-path",Method="GET")
7 在Fiddler中进行测试评估
a Accept:application/xml
b Accept:application/json