开发者

Where to enable metadata (is enabled in config)?

开发者 https://www.devze.com 2022-12-08 08:14 出处:网络
I have a basic wcf service and when I go to the wcfctestclient to test it, I get an error saying metadata could not be found please add it etc. Unfortunately, the MSDN link in the error popup is broke

I have a basic wcf service and when I go to the wcfctestclient to test it, I get an error saying metadata could not be found please add it etc. Unfortunately, the MSDN link in the error popup is broken and my WCF service's app.config has metadata enabled:

  <se开发者_运维技巧rviceBehaviors>
    <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>

Other than that, I haven't changed any metadata settings anywhere else in my code.

Where can I enable metadata to fix the error?


You need to add a metadata exchange (MEX) endpoint to your service node. Try something like this:

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


If you are using Workflow 4.0 with WorkflowServiceHost and loading your service from a xamlx resource, it will not recognize a WCF serviceBehavior tag with a name. I don't know why (seems like a bug to me). For example, this tag from above:

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

would need its name attribute eliminated like this:

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

and the service element would eliminate the reference to the behavior configuration name as in

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


I have answered my own question as it is the only easy way to show the entire file:

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

Thanks for all your help!

0

精彩评论

暂无评论...
验证码 换一张
取 消