i´m getting an "End point not found" when calling a WCF service. It is a Self-hosted service in a console app.
Here is my code:
IService.cs
namespace ClassLibrary
{
[ServiceContract]
public interface IService
{
[OperationContract]
[WebGet]
string GetMessage(string inputMessage);
[OperationContract]
[WebInvoke]
string PostMessage(string inputMessage);
}
}
Service.cs
namespace ClassLibrary
{
public class Service : IService
{
public string GetMessage(string inputMessage)
{
return "En GetMessage llega " + inputMessage;
}
public string PostMessage(string inputMessage)
{
return "En PostMessage llega " + inputMessage;
}
}
}
And the console app:
namespace ConsoleHost
{
class Program
{
static void Main(string[] args)
{
WebServiceHost host = new WebServiceHost(typeof(Service), new Uri("http://localhost:8000"));
ServiceEndpoint ep = host.AddServiceEndpoint(typeof(IService), new WebHttpBinding(), "");
ServiceDebugBehavior db = host.Description.Behaviors.Find<ServiceDebugBehavior>();
db.HttpHelpPageEnabled = false;
ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
smb.HttpGetEnabled = true;
host.Description.Behaviors.Add(smb);
host.Open();
Console.WriteLine("Service is up and running");
Console.WriteLine("Press enter to quit ");
Console.ReadLine();
host.Close();
}
}
}
There is no config file because it is all in the code.
And the call to the service:
http://localhost:8000/
Any help would be much appreciated. Thanks!