我有一个在我的本地VS2010环境中正常运行的WCF休息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&gt; 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休息服务或连接到它。
任何帮助表示赞赏!! 提前谢谢!
答案 0 :(得分:1)
好的,我解决了我的问题。我刚刚重新执行了以下几个步骤,似乎解决了我的问题。我现在可以访问我的Rest网络服务了。