您的位置:首页 > 其它

Restfull分格的 WCF服务简单构建流程

2011-11-10 11:37 441 查看
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: