GurdeepS
GurdeepS

Reputation: 67243

Where to enable metadata (is enabled in config)?

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:

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

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

Where can I enable metadata to fix the error?

Upvotes: 3

Views: 18395

Answers (3)

Peter Bondy
Peter Bondy

Reputation: 11

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

Upvotes: 1

GurdeepS
GurdeepS

Reputation: 67243

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!

Upvotes: 0

Andrew Hare
Andrew Hare

Reputation: 351616

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

Upvotes: 3

Related Questions