您现在的位置:计算机技术学习网 > 技术中心 > WEB编程 > ASP >

How to create RESTful WCF Service(2)

来源:未知 责任编辑:责任编辑 发表时间:2013-12-06 08:44 点击:

p>            BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "/XML/{name}")]  

p>        string GetMessage(string name);  

p>  

p>        [OperationContract]  

p>        [WebInvoke(Method = "GET", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json,  

p>            BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "/JSON/{person}")]  

p>        string GetPerson(string person);  

p>    }  

p>}  

p> 

p>The content of "HelloWorldService.svc" should always be :

p>[html]  

p><!--Host web service-->  

p><%@ServiceHost Service="MyWCFServices.HelloWorldService" %>  

p> 

p>And then we should modify the web.config of "HostDevServer"

p>[html]  

p><?xml version="1.0" encoding="utf-8"?>  

p>  

p><!--  

p>  Pour plus d'informations sur la configuration de votre application ASP.NET, consultez  

p>  http://go.microsoft.com/fwlink/?LinkId=169433  

p>  -->  

p>  

p><configuration>  

p>  <!--Root node of config file-->  

p>  <system.web>  

p>    <compilation debug="true" targetFramework="4.0" />  

p>  </system.web>  

p>  

p>  <system.webServer>  

p>    <modules runAllManagedModulesForAllRequests="true" />  

p>  </system.webServer>  

p>  

p>  <system.serviceModel>  

p>    <!--Top node of WCF Service-->  

p>    <behaviors>  

p>      <serviceBehaviors>  

p>        <!--Specify the bahaviors of a service-->  

p>        <behavior name="MyServiceTypeBehaviors">  

p>          <!-- httpGetEnabled Enable other programs locate the metadata of this web service,   

p>          client applications can't generate proxy and use web service without medatadata-->  

p>          <serviceMetadata httpGetEnabled="true"/>  

p>  

p>          <serviceDebug includeExceptionDetailInFaults="false"/>  

p>        </behavior>  

p>      </serviceBehaviors>  

p>      <endpointBehaviors>  

p>        <behavior name="REST"> <!-- Important -->  
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
用户名: 验证码:点击我更换图片
最新评论 更多>>

推荐热点

  • WAP常见问题问答大全(四)
  • ASP开发必备:WEB打印代码大全
  • ASP调用系统ping命令
  • asp缓存技术
  • ASP教程:第三篇 ASP基础
  • 用ASP+XML打造留言本(4)
  • 关于ASP Recordset 分页出现负数解决方法及建议
  • 用asp怎样编写文档搜索页面(5)
  • ASP处理多关键词查询实例代码
网站首页 - 友情链接 - 网站地图 - TAG标签 - RSS订阅 - 内容搜索
Copyright © 2008-2015 计算机技术学习交流网. 版权所有

豫ICP备11007008号-1