在哪里启用元数据(在配置中启用)?

时间:2009-10-10 00:51:06

标签: .net wcf web-services exception-handling mex

我有一个基本的wcf服务,当我去wcfctestclient进行测试时,我收到错误,说无法找到元数据请添加等等。不幸的是,错误弹出窗口中的MSDN链接被破坏了我的WCF服务app.config已启用元数据:

  <serviceBehaviors>
    <behavior name="TelerikWcfServices.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="False" />
    </behavior>
  </serviceBehaviors>

除此之外,我还没有在我的代码中的任何其他位置更改任何元数据设置。

我在哪里可以启用元数据来修复错误?

3 个答案:

答案 0 :(得分:3)

您需要将元数据交换(MEX)端点添加到服务节点。尝试这样的事情:

<endpoint 
    address="http://host/svc/mex" 
    binding="mexHttpBinding" 
    bindingConfiguration=""
    contract="IMetadataExchange"/>

答案 1 :(得分:1)

如果您正在将Workflow 4.0与WorkflowServiceHost一起使用并从xamlx资源加载服务,则它将无法识别具有名称的WCF serviceBehavior标记。我不知道为什么(对我来说似乎是个错误)。例如,上面的标签:

<serviceBehaviors>
    <behavior name="TelerikWcfServices.Service1Behavior">
      <serviceMetadata httpGetEnabled="True"/>
      <serviceDebug includeExceptionDetailInFaults="False" />
    </behavior>
  </serviceBehaviors>

需要删除其名称属性,如下所示:

<serviceBehaviors>
    <behavior>
      <serviceMetadata httpGetEnabled="True"/>
      <serviceDebug includeExceptionDetailInFaults="False" />
    </behavior>
  </serviceBehaviors>

并且service元素将消除对行为配置名称的引用,如

<service 
    name="TelerikWcfServices.IScheduler">
    <endpoint address="http://localhost/Telerik" binding="basicHttpBinding"
      bindingConfiguration="" name="Telerik"      contract="TelerikWcfServices.IScheduler">...

答案 2 :(得分:0)

我已经回答了我自己的问题,因为这是显示整个文件的唯一简单方法:

                

<client>
  <endpoint address="http://localhost/Telerik" binding="basicHttpBinding"
    bindingConfiguration="" contract="TelerikWcfServices.IScheduler"
    name="Telerik">
    <identity>
      <dns value="localhost" />
      <certificateReference storeName="My" storeLocation="LocalMachine"
        x509FindType="FindBySubjectDistinguishedName" />
    </identity>
  </endpoint>
</client>
<diagnostics>
  <messageLogging logEntireMessage="true" />
</diagnostics>
<services>
  <service behaviorConfiguration="TelerikWcfServices.Service1Behavior"
    name="TelerikWcfServices.IScheduler">
    <endpoint address="http://localhost/Telerik" binding="basicHttpBinding"
      bindingConfiguration="" name="Telerik" contract="TelerikWcfServices.IScheduler">
      <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:8731/Design_Time_Addresses/TelerikWcfServices/Service1/" />
      </baseAddresses>
    </host>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="TelerikWcfServices.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="False" />
    </behavior>
  </serviceBehaviors>
</behaviors>

感谢您的帮助!