创建Restful WCF
来源:互联网 发布:手机怎么发布淘宝宝贝 编辑:程序博客网 时间:2024/05/21 09:27
1. 创建Service类,如下:
[ServiceContract] [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] public class CommonService { [WebGet(UriTemplate = "Common/ServerDateTime/Get")] public DateTime GetServerDateTime() { return DateTime.Now; } [WebInvoke(UriTemplate = "Common/UserName/Get", Method = "POST")] public string GetUserName(string userName) { return "My name is:" + userName; }
2. 创建SVC文件,起名:CommonService.svc,文件内容如下:
<%@ ServiceHost Language="C#" Debug="true" Service="LongCentral.Service.Common.CommonService" %>
其中Service指向第一步创建的Class。
3. 在WebConfig中添加配置文件,如下:
<?xml version="1.0"?><configuration><system.serviceModel><behaviors><serviceBehaviors><behavior name="Framework_WebHost_ServiceBehavior"><serviceMetadata httpGetEnabled="true"/><serviceThrottling maxConcurrentCalls="1000" maxConcurrentSessions="1000" maxConcurrentInstances="1000"/><serviceDebug includeExceptionDetailInFaults="true"/><dataContractSerializer maxItemsInObjectGraph="90000000"/></behavior></serviceBehaviors><endpointBehaviors><behavior name="HelpBehavior"><webHttp helpEnabled="true" faultExceptionEnabled="true" automaticFormatSelectionEnabled="false" defaultOutgoingResponseFormat="Json"/></behavior></endpointBehaviors></behaviors><bindings><webHttpBinding><binding name="Framework_WebHost_WebHttpBinding" allowCookies="false" bypassProxyOnLocal="true" maxBufferPoolSize="65536000" maxReceivedMessageSize="65536000" useDefaultWebProxy="false" closeTimeout="00:50:00" openTimeout="00:50:00" sendTimeout="00:50:00" receiveTimeout="08:00:00"><readerQuotas maxDepth="100" maxStringContentLength="9999990" maxArrayLength="9999990"/><security><transport proxyCredentialType="None"/></security></binding></webHttpBinding></bindings><standardEndpoints><webHttpEndpoint><standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="false" crossDomainScriptAccessEnabled="true"/></webHttpEndpoint></standardEndpoints><services><service name="LongCentral.Service.Common.CommonService" behaviorConfiguration="Framework_WebHost_ServiceBehavior"><endpoint binding="webHttpBinding" bindingConfiguration="Framework_WebHost_WebHttpBinding" behaviorConfiguration="HelpBehavior" contract="LongCentral.Service.Common.CommonService"/></service></services></system.serviceModel></configuration>
0 0
- 创建Restful WCF
- 如何创建restful wcf项目
- (转载)如何创建restful wcf
- 利用WCF创建简单的RESTFul Service
- RESTful WCF
- RESTful WCF
- WCF4.0 -- RESTful WCF Services(创建基于SSL的服务)
- WCF4.0 -- RESTful WCF Services(创建基于SSL的服务)
- WCF4.0 -- RESTful WCF Services(创建基于SSL的服务)
- wcf Restful编程五
- Wcf体现Restful风格
- Ajax调用RESTful WCF
- WCF RESTful CrossDomain 服务
- 【WCF】WCF框架创建
- 构建WCF RESTful service示例
- 通过WCF开发RESTful webService
- Android WCF Restful 服务续
- WCF-创建简单的WCF
- SPI总线协议介绍
- HTTP Header 详解
- cocos2d-x—使用shader使图片背景透明
- 数据库三大范式
- javascript的属性与方法
- 创建Restful WCF
- redis简单测试用例(内存不足,可以使用redis)
- 本文解决两个问题,第一spring.net+nh+mysql 中mysql版本配置问题,第二nh配置问题
- java版的yaml 解析器,试试jyaml
- 利用secureCRT中实现windows和linux的文件互传
- Android Framework 分析---2消息机制Native层
- 简单的Apache服务器配置
- 中石油出售千亿资产背后暗藏啥玄机?
- oracle表连接--->排序合并连接