代码之家  ›  专栏  ›  技术社区  ›  GurdeepS

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

  •  3
  • GurdeepS  · 技术社区  · 15 年前

    我有一个基本的wcf服务,当我去wcftestclient测试它时,我得到一个错误,说找不到元数据,请添加它等。不幸的是,错误弹出窗口中的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 回复  |  直到 10 年前
        1
  •  3
  •   Andrew Hare    15 年前

    您需要向服务节点添加元数据交换(MEX)端点。尝试如下操作:

    <endpoint 
        address="http://host/svc/mex" 
        binding="mexHttpBinding" 
        bindingConfiguration=""
        contract="IMetadataExchange"/>
    
        2
  •  1
  •   Peter Bondy    10 年前

    如果将工作流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 
        name="TelerikWcfServices.IScheduler">
        <endpoint address="http://localhost/Telerik" binding="basicHttpBinding"
          bindingConfiguration="" name="Telerik"      contract="TelerikWcfServices.IScheduler">...
    
        3
  •  0
  •   GurdeepS    15 年前

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

    <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>
    

    谢谢你的帮助!