WCF基本部署到iis 7

时间:2012-08-06 03:17:49

标签: wcf iis-7

我不熟悉部署和wcf,也不确定为什么会发生以下情况

我有一个VS2010 WCF项目,它有一个service.svc和相关的合同,单个查找方法GetStatus接受和返回字符串。根据建议,我将Web.config保留为生成,并注意到它没有定义端点。 然后使用带参数的发布将其部署到本地iis7           ServiceURL:Localhost           站点/应用程序:main / status

然后我去了iis,发现它部署在main / status文件夹结构

但是当我尝试通过指定

使用wcf测试客户端进行访问时
http://localhost/main/status/service.svc or
http://localhost/status/service.svc 

我收到了未找到的错误。

Metadata from http://localhost/main/status/Status.svc If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address.  For help enabling metadata publishing, please refer to the MSDN documentation 

在从iis浏览时我得到同样的错误。

请参阅配置文件(生成)

<?xml version="1.0"?>
<configuration>

  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="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>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>

</configuration>

任何帮助都会很棒

1 个答案:

答案 0 :(得分:0)

请确保您在web.config文件中启用了元数据。

<system.serviceModel>
<behaviors>
<serviceBehaviors>
  <behavior>
    <!-- To avoid disclosing metadata information, set the values 
         below to false before deployment -->
    <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
    <serviceDebug includeExceptionDetailInFaults="false"/>
  </behavior>
</serviceBehaviors>

如果启用了元数据,则该网址上不存在该服务。默认情况下,WCF将使用basicHttpBinding和SOAP 1.1。