0

我对部署和 wcf 相当陌生,不知道为什么会发生以下情况

我有一个 VS2010 WCF 项目,它有一个 service.svc 和关联的合同,带有单一查找方法 GetStatus 接受和返回字符串。根据建议,我将 Web.config 保留为已生成,并注意到它没有定义端点。然后将其部署到本地 iis7,使用带有参数 ServiceURL: Localhost site/application : 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>

任何帮助都会很棒

4

1 回答 1

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>

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

于 2012-08-06T03:41:46.343 回答