WCF休息Web服务在localhost上工作但不在主机上工作

时间:2011-03-29 11:16:46

标签: asp.net wcf web-services iis .net-3.5

我在ASP.net网站内创建了一个简单的WCF Web服务。

网络服务由 IIS 托管,在localhost上运行正常,即访问例如 http://localhost/myservice.svc/HelloWorld我按预期得到了正确的“Hello World”响应。

但是通过我的计算机主机名(http://mycomputer/myservice.svc/HelloWorld)访问它会收到错误404响应。这尤其令人困惑,因为可以从两个方面访问网站的其余部分(主要是aspx页面)而没有任何问题。

我怀疑IIS中存在配置问题,但我没有真正的线索。任何帮助都会非常感激。

我的服务端点如下:

<endpoint address="" binding="webHttpBinding" contract="MyService.Service" />

服务器的错误堆栈跟踪如下:

[EndpointNotFoundException]: There was no channel actively listening at 'http://mycomputer.ad-ent.lan.net/myservice.svc/HelloWorld'. This is often caused by an incorrect address URI. Ensure that the address to which the message is sent matches an address on which a service is listening.
à System.ServiceModel.Activation.HostedHttpTransportManager.HttpContextReceived(HostedHttpRequestAsyncResult result)
   à System.ServiceModel.Activation.HostedHttpRequestAsyncResult.HandleRequest()
   à System.ServiceModel.Activation.HostedHttpRequestAsyncResult.BeginRequest()
[HttpException]: There was no channel actively listening at 'http://mycomputer.ad-ent.lan.net/myservice.svc/HelloWorld'. This is often caused by an incorrect address URI. Ensure that the address to which the message is sent matches an address on which a service is listening.
   à System.ServiceModel.AsyncResult.End[TAsyncResult](IAsyncResult result)
   à System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result)
   à System.ServiceModel.Activation.HostedHttpRequestAsyncResult.ExecuteSynchronous(HttpApplication context, Boolean flowContext)
   à System.ServiceModel.Activation.HttpHandler.ProcessRequest(HttpContext context)
   à System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   à System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

3 个答案:

答案 0 :(得分:0)

请检查服务器的NAT和防火墙设置,请查看以下文章

Working with NATs and Firewalls

答案 1 :(得分:0)

答案 2 :(得分:0)

很老的帖子,我知道。但是为了历史和知识;您可能正在使用代理,在这种情况下,您需要在浏览器设置中为您的计算机名称添加例外。