我有一个在本地 VS2010 环境中运行良好的 WCF REST Web 服务,但是当部署到 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.) Ran 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 休息服务或连接到它。
任何帮助表示赞赏!提前致谢!