开发者

Why can't WCF Restful service be accessed on remote network machine?

I'm having a problem getting RESTful web services working on my local network. Up until recently they were working just fine, and I have no idea what's changed, I'm hoping someone can give me a list of things to check to make sure all my settings are good. I created a very simple test app to see if it was something in my code or my network settings themselves. I created a C# WinForms solution in Visual Studio 2010, and added this into the Form's OnLoad handler:

ServiceHost host = new ServiceHost(typeof(BasicService));
开发者_JAVA技巧string baseUri = "http://" Environment.MachineName + ":876/testing";
ServiceEndpoint point = host.AddServiceEndpoint(typeof(IBasicService), new      WebHttpBinding(), baseUri);
point.Behaviors.Add(new WebHttpBehavior());
host.Open();

The service simply returns a string. I'm able to open up my browser on the local machine and see the string returned just fine. I used to be able to see this on other computers/devices on my local network as well, but now I'm getting a 502 Error Code when I try from a remote machine. Is it possible I need some kind of certificate or network setting toggled?


It won't work because "localhost" always means the current machine. When a remote system tries to access it, it will really be accessing itself!

You need to use the DNS name associated with the externally-visible IP address of the machine running the service.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜