【问题标题】:Deploying a WCF service to IIS 6将 WCF 服务部署到 IIS 6
【发布时间】:2013-12-30 10:41:53
【问题描述】:

我使用 VS2010 创建了一个 wcf 服务,当我从 VS2010 运行它时它可以正常工作,但是当我在 IIS 6 上部署它时(根据 this 帖子),它不起作用。

我做了这些步骤:

  1. 我在我的服务器 (C:\WCFServices\HRService) 中创建了一个文件夹,并将 HRService.svc 和 web.config 复制到其中,并授予 ASPNET 用户对该文件夹的完全访问权限。
  2. 我在上述文件夹中创建了一个Bin 文件夹并将我的服务dll 复制到其中。
  3. 我在我的默认网站中创建了新的虚拟目录(HR):

我的.svc文件,web.Configs如下:

我的.svc 文件

<%@ ServiceHost Language="C#" Debug="true" Service="HumanResourceService.HRService" %>

还有我的web.Config

<?xml version="1.0"?>
<configuration>
<system.web>
  <compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<bindings>
  <basicHttpBinding>
    <binding name="NewBinding0" />
  </basicHttpBinding>
</bindings>
<services>
  <service name="HumanResourceService.HRService">
  <endpoint address="" binding="basicHttpBinding"
     bindingConfiguration="" contract="HumanResourceService.IHRService" >
     <identity>
       <dns value="localhost"/>
     </identity>
  </endpoint>
 <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
 </service>
 </services>
 <behaviors>
 <serviceBehaviors>
   <behavior>
     <serviceMetadata httpGetEnabled="true"/>
     <serviceDebug includeExceptionDetailInFaults="false"/>
   </behavior>
   </serviceBehaviors>
  </behaviors>
 <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
  <modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>

但是当我想通过 IE 访问我的 WCF 服务时,我得到了这个错误:

谁能告诉我,这是什么问题?

【问题讨论】:

    标签: visual-studio-2010 wcf iis deployment web-config


    【解决方案1】:

    确保配置文件中的服务名称与 .svc 文件匹配。在您发布的代码中它没有。您的 .svc 文件具有“HumanResourceService.HRService”,因此&lt;service&gt; 元素的名称属性应匹配:

    <service name="HumanResourceService.HRService">
    

    另外,这是 RESTful 服务还是 SOAP?我问是因为您将webHttpBinding 用于您的服务,即REST。如果不是,我建议basicHttpBindingwsHttpBinding

    如果是 REST,则将其添加到配置文件的行为部分:

    <endpointBehaviors>
      <behavior name="webBehavior">
        <webHttp />
      </behavior>
    </endpointBehaviors>
    

    【讨论】:

    • 我更改了我的 web.config 以匹配 .svc 文件中的服务名称,(我更新了我的帖子),但问题仍然存在(我的服务是 SOAP)。
    • 我,在(msanaei.persiangig.com/Masoud/TestService.rar/download)中也上传了一个简单的示例(VS2010中的默认服务模板)这个示例也有同样的问题。
    【解决方案2】:

    我发现了问题。 在 IIS 和 Web Service Extensions 部分中,ASP.NET V4.0.30319 状态为 Prohibited,我将其更改为 Allowed,问题就解决了。 p>

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-11-26
      • 1970-01-01
      • 1970-01-01
      • 2013-01-21
      • 1970-01-01
      • 1970-01-01
      • 2011-01-01
      • 2016-08-11
      相关资源
      最近更新 更多