如何在IIS 7.5中托管WCF服务?

时间:2014-05-28 06:18:29

标签: c# wcf iis

我正在尝试在IIS服务7.5中托管WCF服务,但是当我尝试浏览svc文件时,从IIS管理器中它会抛出这个错误 enter image description here

当我尝试从Visual Studio 2012本身运行svc文件时,它完全打开了我 enter image description here

我在哪里做错了? web.config文件如下:

<?xml version="1.0"?>
<configuration>

<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5"/>
</system.web>
<system.serviceModel>
<services>
  <service name="GreetMeWcfServiceLibrary.GreetMeService">
    <endpoint address="" binding="basicHttpBinding" contract="GreetMeWcfServiceLibrary.IGreetMeService">
      <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior>
      <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
      <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
      <serviceDebug includeExceptionDetailInFaults="false"/>
    </behavior>
  </serviceBehaviors>
 </behaviors>
 <protocolMapping>
    <add binding="basicHttpsBinding" scheme="https" />
 </protocolMapping>    
 <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<!--
    To browse web app root directory during debugging, set the value below to true.
    Set to false before deployment to avoid disclosing web app folder information.
  -->
<directoryBrowse enabled="true"/>
</system.webServer>

</configuration>

我一直在尝试使用WCF服务库应用程序首先定义服务,然后尝试使用WCF服务进行托管。

此外,当我右键单击并单击web.config文件的WCF配置时,它表示没有服务,但我已添加对该服务库dll的引用。

enter image description here

非常感谢任何帮助:(

2 个答案:

答案 0 :(得分:0)

在您的WCF项目中尝试设置目标FrameWork 4并执行WCF的发布并再次尝试,配置文件将不同,它应该工作。 让我知道

在你的webConfig.xml中试试这个

<?xml version="1.0"?>
<configuration>

  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="true"/>
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>


    <connectionStrings>
      <remove name="XXXXX"/>
      <add name="XXXXXX" connectionString="User ID=sa;Password=XXXX;Initial Catalog=XXXX;Data Source=XXXX\SQLEXPRESS"/>
    </connectionStrings>

</configuration>

答案 1 :(得分:0)

我建议您查看服务器配置,以确保正确安装和配置所有必需的IIS和WCF组件。以下文章概述了该问题以及相关的故障排除建议:
http://www.dotnetscraps.com/dotnetscraps/post/e2809cHTTP-Error-50019-Internal-Server-Errore2809d-in-IIS-7-75.aspx
http://forums.iis.net/t/1166889.aspx