I have a service named WcfService2 (original i know) which has an IService.cs file with a public interface:
namespace WcfService2
{
[ServiceContract]
public interface IService1
{
[OperationContract]
[WebGet(UriTemplate = "/{value}")]
string GetData(string value);
}
}
I then have my public class Service1.svc.cs file which returns a string for the value like so:
namespace WcfService2
{
public class Service1 : IService1
{
public string GetData(string value)
{
return string.Format("You entered: {0}", value);
}
}
}
I am now trying to host this service with a console app like so:
namespace Host
{
class Program
{
static void Main(string[] args)
{
WebHttpBinding binding = new WebHttpBinding();
WebServiceHost host =
new WebServiceHost(typeof(IService1));
host.AddServiceEndpoint(typeof(IService1),
binding,
"http://localhost:8000/Hello");
host.Open();
Console.WriteLine("I DONT LIKE REST!");
Console.WriteLine("Press <RETURN> to KILL REST FOR GOOD");
Console.ReadLine();
}
}
}
But I get an error after I run it:
ServiceHost only supports class service types.
So this obviously relates to my IService being of public interface type. But I dont know how else to create it, when I first created the WCF Service application
it gives you the two standard files IService and Service.svc files if I delete either or, and only Implement this solution in one class when I try to add the web service in local soultion nothing is found.
Is there a way to fiddle with the host code?