将WCF Rest webservice部署到IIS 6.0会出现HTTP错误404-找不到文件或目录
我有一个WCF rest webservice,它在本地VS2010环境中运行良好,但是当部署到windows server 2003上的IIS 6.0时,我收到HTTP错误404-找不到文件或目录。 我搜索过其他有类似问题的帖子,尝试过所有的建议,但都没有结果。 这是我的服务合同:将WCF Rest webservice部署到IIS 6.0会出现HTTP错误404-找不到文件或目录,wcf,rest,iis-6,wcf-rest,Wcf,Rest,Iis 6,Wcf Rest,我有一个WCF rest webservice,它在本地VS2010环境中运行良好,但是当部署到windows server 2003上的IIS 6.0时,我收到HTTP错误404-找不到文件或目录。 我搜索过其他有类似问题的帖子,尝试过所有的建议,但都没有结果。 这是我的服务合同: [ServiceContract] public interface IRestServiceImpl { [OperationContract] [WebInvoke(Method = "PUT
[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
}
}
<%@ ServiceHost Language="C#" Debug="true" Service="CICJIS.IWS.RestServiceImpl"
CodeBehind="RestServiceImpl.svc.cs" %>
RestServiceImpl.svc如下所示:
public class RestServiceImpl : IRestServiceImpl
{
public ExecuteResponse Execute(ExecuteRequest request)
{
//processing code that returns ExecuteResponse
}
public ExecuteResponse Execute(ExecuteRequest request)
{
//processing code that returns ExecuteResponse
}
}
<%@ 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\u isapi.dll
4.)在目录安全中取消选中集成windows身份验证。
5.)在网站属性中将ASP.net版本从2.0更改为4.0
我在同一台服务器和IIS上部署了另一个WCF SOAP Web服务,我可以很好地浏览和连接它。我不明白为什么我无法浏览这个WCF rest服务或连接到它
感谢您的帮助!!
提前谢谢 好的,我解决了我的问题。我只是重复了几次下面的步骤,似乎已经解决了我的问题。我现在可以使用Rest Web服务了
我想补充一点,我试图将我的Web服务发布到我的本地IIS 7,我要做的就是将应用程序池更改为ASP.net 4.0.3并运行ServiceModelReg-I。当我从VS2010发布到运行IIS 6的windows server 2003框时,我复制了在inetput/wwwroot下创建的webservice文件夹,但仍然无法使其运行:(请帮助!!我有关于此的其他信息。我在事件查看器中看到以下错误:无法检测ASP.NET安装或ASP.NET被禁用,跳过Web主机脚本映射组件,因为它依赖于ASP.NET才能正常工作。如果您认为此消息是错误,请检查您的ASP.NET安装以确保它安装正确,版本正确。我通过将1.step更改为aspnet_regiis-I-enable解决了这个问题