Service endpoint not found?
22,962
Remove the / from {value} and make sure it is listed as an OperationContract
. It should be:
[WebGet(UriTemplate = "{value}")]
[OperationContract]
The base URL will come through with the trailing slash, so you are really looking for http://localhost:8000/hello//help
in the current code
Author by
G Gr
New to C# and Matlab, enjoy learning via questions which makes stackoverflow my adopted home!
Updated on March 26, 2020Comments
-
G Gr about 4 years
Seem to run into a service endpoint not found problem when trying to get from my service.
if I try http://localhost:8000/hello/help I should expect to see
<string>You entered help <string>
but I only get the no endpoint instead? I havent touched my config files at all and I am just hosting from a console app.Host:
namespace Host { class Program { static void Main(string[] args) { WebHttpBinding binding = new WebHttpBinding(); WebServiceHost host = new WebServiceHost(typeof(Service1)); host.AddServiceEndpoint(typeof(IService1), binding, "http://localhost:8000/hello"); host.Open(); Console.WriteLine("Hello world service"); Console.WriteLine("Press <RETURN> to end service"); Console.ReadLine(); } } }
Service1:
namespace WcfServiceLibrary1 { // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in both code and config file together. public class Service1 : IService1 { public string GetData(string value) { return string.Format("You entered: {0}", value); }
IService1:
[ServiceContract] public interface IService1 { [WebGet(UriTemplate = "/{value}")] string GetData(string value);