【发布时间】:2011-01-18 23:24:21
【问题描述】:
我以前从未将 WCF 服务部署到 IIS 6。我通过使用默认配置作为 WCF 项目的一部分来部署到 IIS 6 的服务。从那以后,我简化了可能是问题的配置思想。这是我在浏览器中浏览服务时遇到的错误:
HTTP 错误 403.1 - 禁止:执行 访问被拒绝。
我的配置现在如下所示:
<system.serviceModel>
<services>
<service name="MyCompany.WebServices.MyService">
<endpoint address="" binding="basicHttpBinding" contract="MyCompany.WebServices.IMyService" />
</service>
</services>
</system.serviceModel>
如果我尝试将其添加为 ASP.NET MVC 中的引用,我会得到以下信息:
下载时出错 'http://ws.mycompany.com/MyService.svc'。 请求失败,HTTP 状态 403:禁止。元数据包含一个 无法解决的参考: 'http://ws.mycompany.com/MyService.svc'。 HTTP 请求被禁止 客户端认证方案 '匿名的'。远程服务器 返回错误:(403)禁止。如果 该服务在当前定义 解决方案,尝试构建解决方案 并添加服务参考 再次。
有什么想法吗?
更新:
这似乎是我的 IIS 6 机器上的配置问题。我假设这是因为我创建了一个全新的 ASP.NET 3.5 WCF 应用程序并将其部署到http://ws.unitedoneresources.com/Service1.svc 的新 URL。如果我尝试调用该服务,我会收到上面列出的相同 HTTP 错误。整个服务配置如下:
<system.serviceModel>
<services>
<service name="WcfService1.Service1" behaviorConfiguration="WcfService1.Service1Behavior">
<!-- Service Endpoints -->
<endpoint address="" binding="wsHttpBinding" contract="WcfService1.IService1">
<!--
Upon deployment, the following identity element should be removed or replaced to reflect the
identity under which the deployed service runs. If removed, WCF will infer an appropriate identity
automatically.
-->
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="WcfService1.Service1Behavior">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
同样,这是一个全新的 ASP.NET 3.5 WCF 应用程序,所以我没有对项目本身进行任何修改。
【问题讨论】:
-
服务是否托管在您查询的同一台计算机上?
-
不。一个是数据库服务器,另一个是 IIS 服务器。数据库调用都在使用 EF 的类库中处理。
-
我已经更新了上面的问题。我尝试将 IIS Web 设置为具有执行权限,重新启动 IIS,但这不起作用。我也在 IIS7 机器上尝试过,但无济于事。这一定是我做错了什么。
标签: wcf iis iis-6 wcf-security