【问题标题】:Deploying WCF Rest webservice to IIS 6.0 gives HTTP Error 404 - File or directory not found将 WCF Rest web 服务部署到 IIS 6.0 会出现 HTTP 错误 404 - 找不到文件或目录
【发布时间】:2013-05-10 11:55:17
【问题描述】:

我有一个 WCF REST Web 服务,在我的本地 VS2010 环境中运行良好,但在 Windows Server 2003 上部署到 IIS 6.0 时,我收到 HTTP 错误 404 - 找不到文件或目录。 我已经搜索了具有类似问题的其他线程,并尝试了所有建议均无济于事。 这是我的服务合同:

[ServiceContract]
 public interface IRestServiceImpl
{
    [OperationContract]
    [WebInvoke(Method = "PUT", ResponseFormat = WebMessageFormat.Xml,
        BodyStyle = WebMessageBodyStyle.Bare,
        UriTemplate = "Execute")]
    ExecuteResponse Execute(ExecuteRequest request);

    [OperationContract]
    [WebInvoke(Method = "PUT", ResponseFormat = WebMessageFormat.Json,
        BodyStyle = WebMessageBodyStyle.Bare,
        UriTemplate = "ExecutePutJSON")]
    ExecuteResponse ExecutePutJSON(ExecuteRequest request);
}

(RestServiceImpl.svc.cs)背后的实现代码如下:

public class RestServiceImpl : IRestServiceImpl
{
    public ExecuteResponse Execute(ExecuteRequest request)
    {
       //processing code that returns ExecuteResponse
    }

    public ExecuteResponse Execute(ExecuteRequest request)
    {
       //processing code that returns ExecuteResponse
    }
}

RestServiceImpl.svc如下:

<%@ ServiceHost Language="C#" Debug="true" Service="CICJIS.IWS.RestServiceImpl" 
CodeBehind="RestServiceImpl.svc.cs" %>

Web.config:

<configuration>
  <system.diagnostics>
    <sources>
      <source name="System.ServiceModel"
      switchValue="Information, ActivityTracing">
        <listeners>
          <add name="messages" />
        </listeners>
    </source>
  <source name="System.ServiceModel.MessageLogging">
    <listeners>
      <add name="messages" />
    </listeners>
  </source>
 </sources>
 <sharedListeners>
  <add name="messages"
     type="System.Diagnostics.XmlWriterTraceListener"
     initializeData="C:\Logs\RestService.svclog" />
 </sharedListeners>
 <trace autoflush="true" />
 </system.diagnostics>
<system.web>
    <compilation debug="true" defaultLanguage="c#" targetFramework="4.0" />
    <httpRuntime maxRequestLength="999999" maxQueryStringLength="999999"
    executionTimeout="999"/>
</system.web>
<system.serviceModel>
   <diagnostics>
      <messageLogging
        logEntireMessage="true"
        logMalformedMessages="true"
        logMessagesAtServiceLevel="true"
        logMessagesAtTransportLevel="true"
        maxMessagesToLog="3000"
        maxSizeOfMessageToLog="10000000" />
    </diagnostics>

   <services>
      <service name="RestServiceImpl" behaviorConfiguration="ServiceBehavior">
        <endpoint address="" binding="webHttpBinding" contract="IRestServiceImpl" 
          behaviorConfiguration="web">

        </endpoint>
      </service>
    </services>

    <behaviors>
      <endpointBehaviors>
        <behavior name="web">
          <webHttp />
        </behavior>
      </endpointBehaviors>

      <serviceBehaviors>
        <behavior name="ServiceBehavior">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
        <behavior name="">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>

    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>

</configuration>

我尝试了以下方法:

1.) 使用 aspnet_regiis -i 安装 ASP.net 4.0 2.) 运行 C:\WINDOWS\Microsoft.NET\Framework\v3.0\Windows Communication Foundation>Service ModelReg.exe -i 3.)手动修改网站属性中.svc的扩展名映射为.svc指向c:\windows\microsoft.net\framework\v4.0.30319\aspnet_isapi.dll 4.)在目录安全未选中集成Windows身份验证。 5.) 将网站属性上的 ASP.net 版本从 2.0 更改为 4.0。

我将另一个 WCF SOAP Web 服务部署到同一服务器和 IIS,我可以正常浏览和连接它。我不明白为什么我无法浏览或连接到这个 WCF 休息服务。

感谢任何帮助! 提前致谢!

【问题讨论】:

  • 我想补充一点,我试图将我的 web 服务发布到我的本地 IIS 7,我所要做的就是将应用程序池更改为 ASP.net 4.0.3 并运行 ServiceModelReg -一世。当我从 VS2010 发布到运行 IIS 6 的 windows server 2003 框时,我复制了在 inetput/wwwroot 下创建的 webservice 文件夹,但仍然无法运行它。 :(请帮忙!!
  • 我有这方面的更多信息。我在事件查看器中看到以下错误:无法检测到 ASP.NET 安装或 ASP.NET 被禁用,跳过 Web 主机脚本映射组件,因为它依赖于 ASP.NET 才能正常运行。如果您认为此消息是错误的,请检查您的 ASP.NET 安装以确保它已正确安装并且是正确的版本。

标签: wcf rest iis-6 wcf-rest


【解决方案1】:

好的,我解决了我的问题。我只是重新运行了几次以下步骤,它似乎解决了我的问题。我现在可以访问我的 Rest 网络服务了。

  1. 使用 aspnet_regiis -i 安装了 ASP.net 4.0
  2. 跑 C:\WINDOWS\Microsoft.NET\Framework\v3.0\Windows Communication Foundation>Service ModelReg.exe -i

【讨论】:

  • 我通过将您的 1. 步骤更改为 aspnet_regiis -i -enable 解决了问题
猜你喜欢
  • 2018-02-03
  • 2013-11-26
  • 1970-01-01
  • 2021-01-31
  • 2017-02-23
  • 1970-01-01
  • 1970-01-01
  • 2011-02-07
  • 1970-01-01
相关资源
最近更新 更多