http://blog.csdn.net/jiankunking/article/details/44118911
一、 环境vs2010,WCF应用程序,server 2008
第一步:WCF项目右键点击项目,选择生成部署包,如下图:

第二步:WCF项目上右键,选择:在windows资源管理器中打开文件夹,如下图:

第三步:第二步:在你项目所在的文件目录下找到Package文件夹,这就是我们的部署包所在的地方。在这个package文件夹下面有一个packageTmp。


第四步:在IIS上新建虚拟目录,将物理地址指向此文件夹。
1、windows server 2008中没有自带Microsoft .NET Framework 4,因此需要在网上下载,手动安装,安装时右键选择管理员身份运行。
下载地址:http://www.microsoft.com/zh-cn/download/details.aspx?id=17718
2、完成.NET Framework 4后,重启服务器
3、在IIS上新建虚拟目录


点击确定,完成
4、第四部:部署结束。可以在浏览器中查看我们部署的WCF了。

哈哈,结果。。。。

这是应为默认的net版本不对,修改方式如下:

修改后,右键浏览,效果如下:
上图中的http://localhost/Test.svc?wsdl即为我们要引用的服务地址。
注意:如果在别的机器上引用该机的WCF服务时,需要将localhost替换为该机的ip
二、环境 win10 vs2015
今天在本机搭载iis wcf的时候,遇到了以下问题:
WCF HTTP 错误 404.3 - Not Found
WCF 在应用程序级别之外使用注册为 allowDefinition=‘MachineToApplication‘ 的节是错误的。
WCF 找不到类型“WcfServiceStudy.WcfService”,它在 ServiceHost 指令中提供为 Servi
搭建的wcf是:WCF应用程序,具体代码如下:
接口:
- namespace WcfServiceStudy
- {
-
- [ServiceContract]
- public interface IWcfService
- {
- [OperationContract]
- string DoWork();
- }
- }
实现:
- namespace WcfServiceStudy
- {
-
-
- public class WcfService : IWcfService
- {
- public string DoWork()
- {
- return "hello world!";
- }
- }
- }
配置文件如下:
- <?xml version="1.0" encoding="utf-8"?>
- <configuration>
-
- <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>
- <basicHttpBinding>
- <binding maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" name="MyServiceBinding">
- <readerQuotas maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxDepth="2147483647" maxNameTableCharCount="2147483647" maxStringContentLength="2147483647" />
- </binding>
- </basicHttpBinding>
- </bindings>
- <services>
- <service name="WcfServiceStudy.WcfService">
- <endpoint address="Management" binding="basicHttpBinding" bindingConfiguration="MyServiceBinding" contract="WcfServiceStudy.IWcfService">
- </endpoint>
- </service>
- </services>
-
-
- <behaviors>
- <serviceBehaviors>
- <behavior>
-
- <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
-
- <serviceDebug includeExceptionDetailInFaults="true"/>
- </behavior>
- </serviceBehaviors>
- </behaviors>
- <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
- <protocolMapping>
- <add binding="basicHttpsBinding" scheme="https" />
- </protocolMapping>
-
- </system.serviceModel>
- <system.webServer>
- <modules runAllManagedModulesForAllRequests="true"/>
- <!--
- 若要在调试过程中浏览 Web 应用程序根目录,请将下面的值设置为 True。
- 在部署之前将该值设置为 False 可避免泄露 Web 应用程序文件夹信息。
- -->
- <directoryBrowse enabled="true"/>
- </system.webServer>
-
- </configuration>
部署的步骤是:


将WCF应用程序编译后的dll与config,分别放到对应位置

但在iis中浏览的时候,遇到了上面的三个问题。
根据自己的搭建步骤与问题解决,感觉问题出在:右键新建网站完成后。没有在自己新建的网站下添加应用程序,而是直接把网站的物理路径指向了自己新建的文件夹JianKunKingServices中。缺少了在网站下添加应用程序这一步,所有出现了一系列的问题,最后是通过把自己添加的文件夹JianKunKingServices转换为应用程序解决的。
zz部署wcf iis
原文:http://www.cnblogs.com/liangouyang/p/4820722.html