tags:

views:

380

answers:

3

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?

Thanks

A: 

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"/>
Andrew Hare
But then that changes the entire endpoint? I assume I can't use both? So what do I do when I need one of the other bindings?
dotnetdev
Actually you can use both :)
Andrew Hare
A: 

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!

dotnetdev
A: 

I still get the same error.

Error: Cannot obtain Metadata from http://localhost/Telerik If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address. For help enabling metadata publishing, please refer to the MSDN documentation at http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata Exchange Error URI: http://localhost/Telerik Metadata contains a reference that cannot be resolved: 'http://localhost/Telerik'. The remote server returned an unexpected response: (405) Method Not Allowed. The remote server returned an error: (405) Method Not Allowed.HTTP GET Error URI: http://localhost/Telerik The HTML document does not contain Web service discovery information.

I added the endpoint to Client and then Service (not both).

dotnetdev