ptn77 ptn77 - 1 year ago 105
reST (reStructuredText) Question

Deploying WCF Rest webservice to IIS 6.0 gives HTTP Error 404 - File or directory not found

I have a WCF rest webservice that runs fine on my local VS2010 environment, but when deployed to IIS 6.0 on windows server 2003, I get the HTTP Error 404 - File or directory not found.
I've searched other threads with similar questions and tried all the suggestions to no avail.
Here's my service contract:

[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);
}


The implementation code behind (RestServiceImpl.svc.cs) is as follows:

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

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


The RestServiceImpl.svc is as follows:

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


The 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>


I have tried the following:

1.) installed the ASP.net 4.0 using aspnet_regiis -i
2.) Ran C:\WINDOWS\Microsoft.NET\Framework\v3.0\Windows Communication Foundation>Service
ModelReg.exe -i
3.)manually changed the .svc extension mapping in the properties of the website for .svc to point to c:\windows\microsoft.net\framework\v4.0.30319\aspnet_isapi.dll
4.)In directory security unchecked the integrated windows authentication.
5.)Changed the ASP.net version from 2.0 to 4.0 on the website properties.

I have another WCF SOAP webservice deployed to the same server and IIS and I can browse and connect to it fine. I don't understand why I am unable to browse this WCF rest service or connect to it.

Any help is appreciated!!
Thanks in advance!

Answer Source

Ok, I solved my issue. I just re-ran the following steps a couple of times and it seemed to have fixed my problem. I am able to get to my Rest webservice now.

  1. installed the ASP.net 4.0 using aspnet_regiis -i
  2. Ran C:\WINDOWS\Microsoft.NET\Framework\v3.0\Windows Communication Foundation>Service ModelReg.exe -i
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download