iis - 无法访问部署在本地 IIS Web 服务器上的 RESTFul WCF 服务上的 .svc

标签 iis deployment wcf

我需要帮助,我是 WCF 世界的新手,最近刚从 SOAP Web 服务转换过来。

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

我已经在托管在端口 8082 ( http://localhost:8082 ) 上的本地 IIS Web 服务器上设置了一个网站,并创建了一个指向包含我的 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>

最佳答案

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

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

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

马克

关于iis - 无法访问部署在本地 IIS Web 服务器上的 RESTFul WCF 服务上的 .svc,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1639480/

相关文章:

node.js - 如果 IIS 客户端证书身份验证正常,则检查 nodeJS Express

asp.net - 无法部署到 Elastic Beanstalk : ERROR_FILE_IN_USE

deployment - 如何使用 docker 自动化多服务器部署

eclipse - eclipse 和 tomcat 中的 java.lang.NoClassDefFoundError 但是 WAR 在独立的 tomcat 中工作

xml - WCF 数组序列化

wcf - WCF wsHttpBinding 通过防火墙的有趣问题

asp.net-mvc - HTTP 500,customErrors 重定向不起作用

powershell - 使用强制选项在Powershell中创建应用程序池

ruby-on-rails - Rails 5 部署到 VPS - capistrano 错误 "Don' 不知道如何构建任务 'deploy:setup' "

sql - 在多个 Windows 版本中测试 .NET 应用程序