基本思路

1、新建WCF应用程序
2、注册路由(可省略,则用/….svc/….访问)
配置文件

  <appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5.2" />
<httpRuntime targetFramework="4.5.2"/>
</system.web>
<system.serviceModel>
<bindings>
<webHttpBinding>
<binding name="NewBinding0" />
</webHttpBinding>
</bindings>
<services>
<service name="WcfService4.Service1">
<endpoint address="/service" behaviorConfiguration="web" binding="webHttpBinding"
bindingConfiguration="" contract="WcfService4.IService1" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- 为避免泄漏元数据信息,请在部署前将以下值设置为 false -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<!-- 要接收故障异常详细信息以进行调试,请将以下值设置为 true。在部署前设置为 false 以避免泄漏异常信息 -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
<!--<protocolMapping>
<add binding="basicHttpBinding" scheme="http" />
</protocolMapping>-->
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<!--
若要在调试过程中浏览 Web 应用程序根目录,请将下面的值设置为 True。
在部署之前将该值设置为 False 可避免泄露 Web 应用程序文件夹信息。
-->
<directoryBrowse enabled="true"/>
</system.webServer>

访问uri:http://localhost:27472/Service1.svc/service/GetData/1
3、写接口和.svc(服务) 与WCF库完全相同
4、Release模式下生成项目并发布(避免源代码暴露)
5、IIS下托管
托管成网站(添加网站),确定端口
访问:http://localhost:端口号/Service1.svc/service/GetData/1
localhost可改为IP地址


注意

服务引用BLL、DAL+EF之类的,引用项目,并把相关配置拷贝到最后服务的配置文件里面
比如,数据库连接字符串,EF相关配置,其他功能授权相关内容等等


配置文件参考

服务器发布后的配置文件:(Web.config)
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
<system.serviceModel>
<bindings>
<webHttpBinding>
<binding name="NewBinding0" />
</webHttpBinding>
</bindings>
<services>
<service name="WcfService4.Service1">
<endpoint address="/service" behaviorConfiguration="web" binding="webHttpBinding" bindingConfiguration="" contract="WcfService4.IService1" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- 为避免泄漏元数据信息,请在部署前将以下值设置为 false -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<!-- 要接收故障异常详细信息以进行调试,请将以下值设置为 true。在部署前设置为 false 以避免泄漏异常信息 -->
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
<!--<protocolMapping>
<add binding="basicHttpBinding" scheme="http" />
</protocolMapping>-->
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<!--
若要在调试过程中浏览 Web 应用程序根目录,请将下面的值设置为 True。
在部署之前将该值设置为 False 可避免泄露 Web 应用程序文件夹信息。
-->
<directoryBrowse enabled="true" />
<!--以下是IIS托管后自动添加的部分-->
<handlers>
<remove name="ISAPI-dll" />
<add name="test2" path="*.svc" verb="*" modules="IsapiModule" scriptProcessor="D:\WcfService4\bin\WcfService4.dll" resourceType="File" preCondition="bitness32" />
<add name="test" path="*.dll" verb="*" modules="IsapiModule" scriptProcessor="Dhua555:\WcfService4\bin\WcfService4.dll" resourceType="File" preCondition="bitness32" />
</handlers>
</system.webServer>

WCF服务的IIS托管(网站托管)的更多相关文章

  1. WCF服务的IIS托管(应用程序)

    基本思路 建立与发布参考网站托管 在IIS中某一网站,选择添加应用程序   访问服务uri:http://localhost/wcfAppTest/Service1.svcwcfAppTest/Ser ...

  2. WCF 一步一步 发布 WCF服务 到 IIS (图)

    WCF 一步一步 发布 WCF服务 到 IIS (图) 使用VS自带的WCFSVCHost(WCF服务主机)发布WCF服务,时刻开发人员测试使用. 下面我们来看一下如何在IIS中部发布一个WCF服务. ...

  3. .Net WCF服务部署IIS详细解析

    官方解析:Windows Communication Foundation(WCF)是由微软开发的一系列支持数据通信的应用程序框架,可以翻译为Windows 通讯开发平台.整合了原有的windows通 ...

  4. WCF服务部署IIS

    一.将WCF服务部署到IIS上  [转载自简单笑容——http://www.cnblogs.com/skdsxx/p/5072726.html ] 1.首先检测电脑上是否安装了IIS,一般来说Win7 ...

  5. WCF服务寄宿IIS与Windows服务 - C#/.NET

    WCF是Windows平台下程序间通讯的应用程序框架.整合和 .net Remoting,WebService,Socket的机制,是用来开发windows平台上分布式开发的最佳选择.wcf程序的运行 ...

  6. WCF服务寄宿IIS与Windows服务

      WCF是Windows平台下程序间通讯的应用程序框架.整合和 .net Remoting,WebService,Socket的机制,是用来开发windows平台上分布式开发的最佳选择.wcf程序的 ...

  7. WCF入门(六)---主机WCF服务

    建立一个WCF服务后,下一步就是托管它,以便客户端应用程序可以使用,这就是所谓的WCF服务托管. WCF服务可以通过使用任何的四种方法如下托管. IIS主机 - IIS是Internet信息服务的缩写 ...

  8. Azure开发者任务之七:在Azure托管服务中托管WCF服务角色

    在一个托管服务中托管一个WCF服务角色和托管一个ASP.Net Web Role基本类似. 在上一篇文章中,我们学习了如何使用WCF Service Web Role. 在本文中,我会对上一篇文章进行 ...

  9. 创建WCF服务寄宿到IIS

    一.WCF简介: Windows Communication Foundation(WCF)是由微软开发的一系列支持数据通信的应用程序框架,可以翻译为Windows 通讯开发平台. 整合了原有的win ...

随机推荐

  1. 程序猿的还有一出路:大数据project师

    非常多年前我非常郁闷地写了一篇博客<程序猿的出路在哪里?>,之所以郁闷.我记得是看了中国男足的比赛,不由自主对照自已苦逼的程序猿生涯,以前对中国软件的感情有如对中国男足,绝望到没有不论什么 ...

  2. php实现表示数值的字符串(is_numeric($s))

    php实现表示数值的字符串(is_numeric($s)) 一.总结 is_numeric($s) 二.php实现表示数值的字符串 题目描述 请实现一个函数用来判断字符串是否表示数值(包括整数和小数) ...

  3. 忙里偷闲( ˇˍˇ )闲里偷学【C语言篇】——(8)枚举、补码

    一.枚举 # include <stdio.h> enum WeekDay //定义了一个数据类型(值只能写以下值) { MonDay, TuesDay, WednesDay, Thurs ...

  4. HTML代码简写法:Emmet和Haml(转)

    HTML代码写起来很费事,因为它的标签多. 一种解决方法是采用模板, 在别人写好的骨架内,填入自己的内容.还有一种就是我今天想要介绍的方法----简写法. 常用的简写法,目前主要是Emmet和Haml ...

  5. 微信开发学习日记(七):开源微商城wemall

    最近嘛,不是在调研PHP和微信的行情么. 发现,微商城是非常火爆的一个领域,既然业务有搞头,那么技术这一块也有很多选择. 网上发现了wemall这个开源的PHP实现的微商城. 下载了开源版本,PHP后 ...

  6. 判断系统64位(使用GetNativeSystemInfo函数,XP时代就有这个函数了)

    判断系统64位 static bool IsWin64 (void) { SYSTEM_INFO si = {0}; typedef void (WINAPI *LPFN_PGNSI)(LPSYSTE ...

  7. 阿里云服务器apache服务器局域网访问公网访问配置

    阿里云服务器apache服务器局域网访问公网访问配置 一.总结 一句话总结: 1.再总结-------------------------------------------------------- ...

  8. android --Activity生命周期具体解释

    一. 再探Activity生命周期 为了研究activity的生命周期,简单測试代码例如以下. package com.example.testactivity; import android.app ...

  9. XMPP之ios即时通讯客户端开发-mac上搭建openfire服务器(二)

    come from:http://www.cnblogs.com/xiaodao/archive/2013/04/05/3000554.html 一.下载并安装openfire 1.到http://w ...

  10. android studio报错提示: Gradle DSL method not found: 'android() 解决方案

    原文错误提示: Error:(16, 0) Gradle DSL method not found: 'Android()'Possible causes:<ul><li>Th ...