I followed this example to make my first WCF service: WCF REST Service JSON, then edited it to create my own. I was able to get my service to run fine in debugging using ASP.NET Developer Server. I opened port 8081(on the Server, Firewall and Router) and then assigned it to the “Registration” folder in IIS. I then published the service to a Windows Server 2003 running IIS 6 after spending a day figuring out I had to use MsDeployAgentService. I then set the ASP.NET version to 4.0.3019 using the IIS. The Registration folder contains Service1.svc, Web.config, and the bin folder.
This is my web config file:
<?xml version="1.0"?>
<configuration>
<configSections>
</configSections>
<connectionStrings>
<add name="ServiceApp.Properties.Settings.RegistrationConnection"
connectionString="Data Source=EDITED;Initial Catalog=Registration;Persist Security Info=True;User ID=EDITED;Password=EDITED;MultipleActiveResultSets=True" />
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<httpRuntime maxRequestLength="524288" />
</system.web>
<system.serviceModel>
<bindings>
<webHttpBinding>
<binding name="StreamedRequestWebBinding"
bypassProxyOnLocal="true"
useDefaultWebProxy="false"
hostNameComparisonMode="WeakWildcard"
sendTimeout="10:15:00"
openTimeout="10:15:00"
receiveTimeout="10:15:00"
maxReceivedMessageSize="2147483647"
maxBufferSize="2147483647"
maxBufferPoolSize="2147483647"
transferMode="StreamedRequest">
<readerQuotas maxArrayLength="2147483647"
maxStringContentLength="2147483647" />
</binding>
</webHttpBinding>
</bindings>
<services>
<service name="ServiceApp.Service1" behaviorConfiguration="ServiceBehaviour">
<endpoint address="" binding="webHttpBinding" bindingConfiguration="StreamedRequestWebBinding" contract="ServiceApp.IService1" behaviorConfiguration="web">
</endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehaviour">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
When I try to consume the service with a test client I get Error 404 with the following statement
byte[] data = client.DownloadData("http://ServerIP:8081/Registration/Service1.svc/CheckSoftware/1/Customer1/1_0/abc123/1/1");
When I remove the port I get an Error 401 “Not Authorized”
byte[] data = client.DownloadData("http://ServerIP/Registration/Service1.svc/CheckSoftware/1/Customer1/1_0/abc123/1/1");
I have tried using the LAN IP aswell as the WAN IP address.
Followed this post because it looks liked the OP followed the same example and had simalar problems but It didn’t help.
I then looked in the Event Viewer on the server and found this when I included in the port number:
WebHost failed to process a request.
Sender Information: System.ServiceModel.Activation.HostedHttpRequestAsyncResult/23878916
Exception: System.Web.HttpException (0x80004005): The service '/Registration/Service1.svc' does not exist. ---> System.ServiceModel.EndpointNotFoundException: The service '/Registration/Service1.svc' does not exist.
at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath)
at System.ServiceModel.ServiceHostingEnvironment.EnsureServiceAvailableFast(String relativeVirtualPath)
at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.HandleRequest()
at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.BeginRequest()
at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result)
at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result)
Process Name: w3wp
Process ID: 3460
I can clearly see the Service1.svc file exist in the folder. I am pretty lost at this point and would appreciate any help.
EDITED TO INCLUDE MORE CODE:
namespace ServiceApp
{
[ServiceContract]
public interface IService1
{
[OperationContract]
[WebInvoke(Method = "GET",
UriTemplate = "/CheckSoftware/{SoftwareId}/{CustomerId}/{Version}/{Key}/{MoboID}/{ProcessorID}",
RequestFormat = WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json)]
SoftwareStatus CheckSoftware(string SoftwareID, string Version, string CustomerID, string Key, string moboID, string processorID);
[OperationContract]
[WebInvoke(
Method = "GET",
UriTemplate = "/SaveKey/{SoftwareId}/{CustomerId}/{Key}/{MoboID}/{ProcessorID}",
RequestFormat = WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json)]
string SaveKey(string SoftwareID, string CustomerID, string Key, string moboID, string processorID);
}
[DataContract]
public class FileInformation
{
[DataMember]
public string Name
{
get;
set;
}
[DataMember]
public byte[] Content
{
get;
set;
}
}
[DataContract]
public class Employee
{
[DataMember]
public int Id
{
get;
set;
}
[DataMember]
public string Name
{
get;
set;
}
}
[DataContract]
public class SoftwareKey
{
[DataMember]
public string SoftwareId
{
get;
set;
}
[DataMember]
public string CustomerId
{
get;
set;
}
[DataMember]
public string Version
{
get;
set;
}
[DataMember]
public string Key
{
get;
set;
}
}
[DataContract]
public class SoftwareStatus
{
[DataMember]
public Boolean SoftwareId
{
get;
set;
}
[DataMember]
public Boolean CustomerId
{
get;
set;
}
[DataMember]
public Boolean Version
{
get;
set;
}
[DataMember]
public Boolean Key
{
get;
set;
}
[DataMember]
public Boolean HardwareID
{
get;
set;
}
}
}
When using IIS 6.0 for a Service I didn’t need to include the folder name in the URL. So simply changing one line of code solved my problems.