【问题标题】:How to host a WCF service in IIS 7.5?如何在 IIS 7.5 中托管 WCF 服务?
【发布时间】:2014-05-28 06:18:29
【问题描述】:

我正在尝试在 IIS 服务 7.5 中托管 WCF 服务,但是当我尝试浏览 svc 文件时从 IIS 管理器向我抛出此错误

当我尝试从 Visual Studio 2012 本身运行 svc 文件时,它再次从我这里完美打开

我哪里做错了? 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 的引用。

非常感谢任何帮助:(

【问题讨论】:

标签: c# wcf iis


【解决方案1】:

在您的 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>

【讨论】:

  • 什么操作系统在开发中使用以及哪个版本的 VisualStudio? IIS 7.5 有什么操作系统?
  • 此外,当我右键单击并单击 web.config 文件的 WCF 配置时,它说没有服务,但我已经添加了对该服务库 dll 的引用。
【解决方案2】:

我建议您检查服务器配置以确保正确安装和配置所有必要的 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

【讨论】:

    猜你喜欢
    • 2011-07-25
    • 1970-01-01
    • 2022-12-13
    • 1970-01-01
    • 2020-04-26
    • 1970-01-01
    • 1970-01-01
    • 2013-01-05
    相关资源
    最近更新 更多