Service endpoint not found?

It seems that when trying to get from my service a launch to the service endpoint was not found.

if I try http: // localhost: 8000 / hello / help I should expect to see <string>You entered help <string> , but instead I get only the endpoint? I didn’t touch my configuration files at all, and I'm just hosting from a console application.

Leading:

 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); 
+4
source share
2 answers

Remove / from {value} and verify that it is listed as OperationContract . It should be:

 [WebGet(UriTemplate = "{value}")] [OperationContract] 

The base url will go with a trailing slash, so you're really looking for http://localhost:8000/hello//help in the current code

+6
source

Blow in the dark ... by default, arbitrary processes are not allowed to listen on network ports.

When IIS is installed, the account that runs IIS is granted permission — if you want other applications to be started by other accounts (console applications, Windows services) in order to be able to listen on the port, you need to grant permission.

Mark netsh add urlacl as a starting point.

0
source

Source: https://habr.com/ru/post/1403357/


All Articles