How to configure REST service for WCF self-service?

I am trying to host some WCF RESTful services from my computer for use by computers on the local network. I have no experience with WCF, and I'm pretty much a newbie when it comes to that. I created a very basic, truncated console application to see if I could make it work.

static void Main(string[] args) { Uri httpUrl = new Uri("http://localhost:8090/"); var host = new WebServiceHost(typeof(TestClass), httpUrl); var binding = new WebHttpBinding(); // NetTcpBinding(); host.AddServiceEndpoint(typeof(ITestClass), binding, "testing"); ServiceDebugBehavior stp = host.Description.Behaviors.Find<ServiceDebugBehavior>(); stp.HttpHelpPageEnabled = false; host.Open(); Console.WriteLine("Commence with the testing!"); Console.ReadLine(); host.Close(); } 

Here's the service code:

 [ServiceContract] public interface ITestClass { [WebGet] [OperationContract] string TestMethod(); } public class TestClass : ITestClass { public string TestMethod() { return "SUCCESS"; } } 

From a browser on my local computer, I can send a simple receive request and receive

 <string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">SUCCESS</string> 

However, it seems that I cannot send this service from any browsers on my home network when I type http://<service machine IP>:8090/testing/testmethod .

Can someone tell me what configuration is missing so that the service is visible to other computers on my local network without using a DNS server?

+7
c # rest wcf
source share
2 answers

You may need to register the port with the netsh command:

 netsh http add urlacl url=http://+:8090/ user=\Everyone 

Also make sure that you have disabled the firewall on the computer on which this service is installed. Otherwise, it is possible that this may block traffic on port 8090 .

+4
source share

here you go .. my blog.

Self Hosted RestService

+6
source share

All Articles