I have allready built a wcf web service and am having it work great on my local mashine by using my private IP address. However when I attempt to access it on another network the browser fails to connect. I understand that there is a public IP address and have tried switching over to it but with that both my own computer and computers on other networks have failed.
The code I am using is:
WebServiceHost host = new WebServiceHost(typeof(serviceSetup), new Uri("http://PublicIp:8000"));
ServiceEndpoint ep = host.AddServiceEndpoint(typeof(serviceContract), new WebHttpBinding(), "/");
ep.Behaviors.Add(new WebHttpBehavior());
host.Open();
/*
WebServiceHost myHost = new WebServiceHost(typeof(serviceSetup), new Uri("http://PrivateIP:8000"));
ServiceEndpoint myep = myHost.AddServiceEndpoint(typeof(serviceContract), new WebHttpBinding(), "/");
myep.Behaviors.Add(new WebHttpBehavior());
myHost.Open();
*/
What am I doing wrong? Is it a non-code problem like a firewall block? Or do I not understand something about IP addresses?
The problem was that I was behind a router which blocked my computer from hosting on the public IP address. The solution was to map a port on my router to my computer so that my app could pick up incoming requests. Big thanks to Mark Hall who pointed me in the right direction in the comments.