【问题标题】:Service published in IIS says "Metadata publishing for this service is currently disabled"IIS 中发布的服务显示“此服务的元数据发布当前已禁用”
【发布时间】:2016-10-03 19:20:32
【问题描述】:

我使用的是 VS2010 Win 2008 R2。我创建了一个“WCF 服务库”,将它放在 IIS 的虚拟目录中,并将其转换为应用程序。

我将 svc 文件放在应用程序的根目录中,并将输出构建路径更改为 bin。每次尝试 URL http://localhost/test1/Service1.svc 时,我都会收到错误“此服务的元数据发布当前已禁用”

我还尝试了 URL http://localhost/test1/MEX。 Mex 行为配置正确,但出现此错误。

当我尝试向控制台应用程序添加服务引用时,它也找不到服务的元数据。

【问题讨论】:

  • 你试图找到什么?请显示您的 web.config 的相关部分(system.serviceModel 部分)。另外,bin 目录是否在test1 目录中?另外,请查看this questionthis one,因为它们包含很多有用的答案,您可以查看。

标签: wcf iis


【解决方案1】:

你能分享一下你的配置文件 serviceBehavior 部分吗?

启用元数据交换应该是这样的。

<serviceBehaviors>
   <behavior name="SampleServiceBehavior">
          <!-- 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>

【讨论】:

    【解决方案2】:

    这里是配置文件:

    <configuration>
      <system.serviceModel>
        <services>
         <service name="WcfServiceLibrary4.Service1" behaviorConfiguration="ServiceBehavior">
            <host>
              <baseAddresses>
                <add baseAddress="http://localhost/test/"/>
              </baseAddresses>
            </host>
    
            <endpoint address="" binding="basicHttpBinding"
               contract="WcfServiceLibrary4.IService1"/>
    
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
          </service>
        </services>
        <behaviors>
          <serviceBehaviors>
            <behavior name="ServiceBehavior">
    
              <serviceMetadata httpGetEnabled="true"/>
              <serviceDebug includeExceptionDetailInFaults="false"/>
            </behavior>
          </serviceBehaviors>
        </behaviors>
      </system.serviceModel>
    </configuration>
    

    我首先启用了对虚拟文件夹的匿名访问,然后我看到“此服务的元数据发布当前已禁用。”-错误。
    我试过“http://localhost/test/mex”,但 IIS 说“没有这样的资源”。在这里我提到“test”而不是“test1”,因为我更改了虚拟文件夹。 Bin 文件夹在测试下,并且从我设置为 Bin 而不是 Bin/Debug 的项目构建中输出。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-11-16
      • 1970-01-01
      • 1970-01-01
      • 2023-03-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多