【问题标题】:Cannnot access .svc on a RESTFul WCF Service deployed on local IIS WebServer无法访问本地 IIS Web 服务器上部署的 RESTFul WCF 服务上的 .svc
【发布时间】:2009-10-28 19:18:00
【问题描述】:

我需要帮助,我最近刚从 SOAP Webservices 过渡到 WCF 世界。

当我从 VS2008 ASP.NET 开发服务器(即调试模式)运行时,WCF 服务运行良好。当我尝试通过 IIS 访问服务时,问题就出现了。

我在我的本地 IIS Web 服务器上设置了一个网站,该服务器托管在端口 8082 (http://localhost:8082) 上,并创建了一个指向包含我的 WCF 服务代码的物理目录的 VirtualDirectory (1.0)。该网站设置为执行 ASP.NET 2.0.50727。我可以访问登录页面以及各种 .aspx 页面,但是当我尝试访问 Service.svc 时,浏览器永远不会到达那里,只是处于空闲状态。

http://localhost:8082/1.0/Service.svc  

我的问题是我缺少什么设置才能让服务在 IIS 内部工作,因为我已经知道它在开发服务器下工作。

如果有帮助,我将附上我的 web.config 的一部分。

    <system.serviceModel>
    <services>
        <service name="Service1" behaviorConfiguration="Service1Behavior">
            <!-- Service Endpoints -->
            <endpoint address="" binding="wsHttpBinding" contract="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="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="true"/>
            </behavior>
        </serviceBehaviors>
    </behaviors>
</system.serviceModel>

【问题讨论】:

    标签: iis deployment wcf


    【解决方案1】:

    您谈论的是 RESTful 服务,但您使用的是 wsHttpBinding.... 这不是 REST 绑定 - 那将是“webHttpBinding”。

    在大多数情况下,WCF 服务基于 SOAP - 除了 webHttpBinding 之外的任何绑定都是 SOAP 端点,因此您的 wsHttpBinding 端点绝对不是 RESTful in任何方式,形状或形式。您可以使用例如与它通信SoapUI 或更好 - Visual Studio 文件夹中的 WcfTestClient。

    但是,您不能期望仅通过浏览该 URL 就可以从中获取 XML 格式的数据。

    马克

    【讨论】:

      【解决方案2】:

      默认情况下未配置 IIS 7.0 对于 WCF 服务,我们将 配置 IIS 7.0 以运行 WCF 服务 我将打破整个程序 步骤。

      http://basitblog.wordpress.com/2010/01/12/deploy-wcf-service-over-iis-7-0/

      【讨论】:

      • 您需要在待办事项列表中再添加一项。可能重新安装最新的框架并检查是否设置了 IIS(我只是遇到了它以某种方式跳回 2.0 的问题,这导致我延迟了几天)。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-26
      相关资源
      最近更新 更多