1、添加WCF服务库

2、在global里面注册路由

 RouteTable.Routes.Add(new ServiceRoute("api", new WebServiceHostFactory(), typeof(api.OpenApi.OpenApi)));

3、在webconfig里面添加如下配置

 <system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<standardEndpoints>
<webHttpEndpoint>
<standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true" crossDomainScriptAccessEnabled="false" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" maxBufferPoolSize="4194304" />
</webHttpEndpoint>
</standardEndpoints>
<bindings>
<webHttpBinding>
<binding closeTimeout="04:01:00"
openTimeout="04:01:00" receiveTimeout="04:10:00" sendTimeout="04:01:00"
allowCookies="false" bypassProxyOnLocal="false"
hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647" maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647"> <readerQuotas maxDepth="128" maxStringContentLength="2147483647" maxArrayLength="2147483647"
maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
</binding>
</webHttpBinding>
<!--发短信-->
<basicHttpBinding>
<binding name="serviceSoap" />
</basicHttpBinding>
<!--发短信-->
</bindings>
<!--发短信-->
<client>
<endpoint address="http://api5.nashikuai.cn/service.asmx" binding="basicHttpBinding"
bindingConfiguration="serviceSoap" contract="smsServices.serviceSoap"
name="serviceSoap" />
</client>
<!--发短信-->
</system.serviceModel>

  

在c#下用 WCF编写restful的更多相关文章

  1. 在IIS8.5的环境下配置WCF的Restful Service

    今天在客户的环境中(Windows Server 2012 R2 + IIS 8.5)搭建Call WCF Restful Service的功能,发现了几个环境配置的问题,记录如下: 1):此环境先安 ...

  2. Django编写RESTful API(一):序列化

    欢迎访问我的个人网站:www.comingnext.cn 关于RESTful API 现在,在开发的过程中,我们经常会听到前后端分离这个技术名词,顾名思义,就是前台的开发和后台的开发分离开.这个技术方 ...

  3. Django编写RESTful API(四):认证和权限

    欢迎访问我的个人网站:www.comingnext.cn 前言: 按照前面几篇文章里那样做,使用Django编写RESTful API的基本功能已经像模像样了.我们可以通过不同的URL访问到不同的资源 ...

  4. Spring Boot 2.x 编写 RESTful API (五) 单元测试

    用Spring Boot编写RESTful API 学习笔记 概念 驱动模块 被测模块 桩模块 替代尚未开发完毕的子模块 替代对环境依赖较大的子模块 (例如数据访问层) 示例 测试 Service @ ...

  5. Spring Boot 2.x 编写 RESTful API (四) 使用 Mybatis

    用Spring Boot编写RESTful API 学习笔记 添加依赖 <dependency> <groupId>org.mybatis.spring.boot</gr ...

  6. RESTful规范与django编写restful接口

    一.什么是RESTful规范 ①REST与技术无关,代表的是一种软件架构风格,REST是Representational State Transfer的简称,中文翻译为“表征状态转移” ②REST从资 ...

  7. Mono下的WCF的Bug?

    最近一段时间,一直在折腾Mono,折腾Linux.让我无比痛苦的是Mono下的WCF的坑真的是太多了,这不又遇到了一个莫名其妙的问题. 环境:mono 3.2.1,Jexus 5.4.3,OS Cen ...

  8. 利用 Django REST framework 编写 RESTful API

    利用 Django REST framework 编写 RESTful API Updateat 2015/12/3: 增加 filter 最近在玩 Django,不得不说 rest_framewor ...

  9. .Net Core下使用WCF

    在.net core 下的wcf 和framework下的wcf使用方式有点不太一样.在core下用wc,需要安装VS扩展Visual Studio WCF Connected Service,目前这 ...

随机推荐

  1. BASIC-4_蓝桥杯_数列特征

    示例代码: #include <stdio.h>#include <stdlib.h> int main(void){ int n = 0 ; int i = 0 ,  max ...

  2. VBA 自动得到分数

    ' 将一个正数除以 y 返回一个整数或分数 Function RFs(ByVal x As Integer) As String Then RFs = Exit Function End If Dim ...

  3. SqlBulkCopy 快速插入数据

    [转]本文来自http://msdn.microsoft.com/zh-cn/library/system.data.sqlclient.sqlbulkcopy(v=vs.80).aspx 此代码用于 ...

  4. 1001 A+B Format (20 分)

    1001 A+B Format (20 分) Calculate a+b and output the sum in standard format -- that is, the digits mu ...

  5. java单机操作redis3.2.10和集群操作增删改查

    先直接附上单机版的连接和增删改查,7000-7005是端口号 package com.yilian.util; import java.util.HashMap; import java.util.I ...

  6. 第6章 进程控制(3)_wait、exec和system函数

    5. 等待函数 (1)wait和waitpid 头文件 #include <sys/types.h> #include <sys/wait.h> 函数 pid_t wait(i ...

  7. Delphi Webbrowser使用方法详解(一)

    1.webbroser介绍 该组件是一个浏览器组件,可以显示一个指定地址的网页.设置网页打开时的主页以及对网页进行相关的操作,同时也可以对HTML文件进行剪切.复制.粘贴.删除等操作.该 组件在Int ...

  8. Oracle 存储过程 延迟执行 DBMS_LOCK.SLEEP(60);

      --测试代码: declare -- Local variables here i integer; begin -- Test statements here dbms_output.put_l ...

  9. jenkins 构建一个maven项目

    1.首先在 全局工具配置 里配置maven的路径信息 这里因为之前已经下载了maven并放在了E盘,因此只需要在 MAVEN_HOME 添加maven文件夹的路径 如若本地还没maven,勾选 “自动 ...

  10. form表单提交参数封装

    function getFormValues(element,options) { var data = {}; if(element == null || element == undefined) ...