【问题标题】:WCF rest web service working on localhost but not on hostWCF REST Web 服务在本地主机上工作但不在主机上
【发布时间】:2011-07-25 04:55:41
【问题描述】:

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

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)

【问题讨论】:

  • 您的 web.config 中有什么 - 元素?我在 MSDN 中看不到任何将其限制为仅本地主机的内容,但我不是这里的专家,我猜这就是问题所在。
  • 你运行的是什么版本的 IIS?
  • 在 iis admin 中右键单击 svc 文件并选择“浏览”会发生什么?
  • 我正在运行 IIS 7.5。当我右键单击 svc 文件并选择浏览时,服务页面(在本地主机上)在我的浏览器中打开并正常工作。

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


【解决方案1】:

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

Working with NATs and Firewalls

【讨论】:

  • 我的服务器位于我的计算机上,并且相应的端口 (80) 是完全开放的,这表明网站的其余部分正在运行。问题出在其他地方。
【解决方案2】:

【讨论】:

  • 他说他可以使用非本地 IP 访问 .aspx 页面,所以对我来说听起来不像。
  • 安装wireshark,看看它在做什么。它可能会为您提供有关请求去向的线索。 wireshark.org
【解决方案3】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-01-15
    • 1970-01-01
    • 2023-03-21
    • 1970-01-01
    • 2013-04-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多