【发布时间】: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