WCF Metadata not available when browsing directly

When I browse to the .svc I continually get the error: Metadata publishing for this service is currently disabled.

I have followed all of the instructions listed on the error page (added the behavior, referenced the behavior, added the mex endpoint, tried both with and without baseaddress), along with the instructions on MSDN: http://msdn.microsoft.com/en-us/library/ms734765.aspx (pretty much the same, but include the policyversion). I even gutted my config file and only left this stuff - it just doesn't make any difference at all. I've confirmed that the config file is being used (i.e. make a mistake in it, and the error changes).

Section looks like:

<system.serviceModel>
  <services>
    <service name="HoldingService" behaviorConfiguration="SimpleServiceBehavior">
      <host>
        <baseAddresses>
          <add baseAddress="http://localhost/xxxx.cdf.holding/HoldingService.svc"/>
        </baseAddresses>
      </host>
      <endpoint address=""
                binding="basicHttpBinding"
                contract="Xxx.Xxxx.Schema.Service.Cdf.Holding.IHoldingService" />
      <endpoint address="mex"
                binding="mexHttpBinding"
                contract="IMetadataExchange" />
    </service>
  </services>
  <behaviors>
    <serviceBehaviors>
      <behavior name="SimpleServiceBehavior">
        <serviceMetadata httpGetEnabled="True" policyVersion="Policy15" />
      </behavior>
    </serviceBehaviors>
  </behaviors>
</system.serviceModel>

Is there any way at all to fix or debug this?

Answers


I managed to resolve this. The problem was name="HoldingService". Even though the .svc is in the same project as the .config, it needed to be fully qualified (i.e. name="Xxx.Xxxx.Web.Cdf.Holding.HoldingService").

The final code looks like this and works perfectly:

<system.serviceModel>
  <services>
    <service name="Xxx.Xxxx.Web.Cdf.Holding.HoldingService" behaviorConfiguration="SimpleServiceBehavior">
      <endpoint address=""
                binding="basicHttpBinding"
                contract="Xxx.Xxxx.Schema.Service.Cdf.Holding.IHoldingService" />
    </service>
  </services>
  <behaviors>
    <serviceBehaviors>
      <behavior name="SimpleServiceBehavior">
        <serviceMetadata httpGetEnabled="True" />
      </behavior>
    </serviceBehaviors>
  </behaviors>
</system.serviceModel>

As an aside, the way I ended up resolving this was by using the "Microsoft Service Configuration Editor" (accessible via Tools > WCF Service Configuration Editor in VS2010). I didn't know this existed and had been hand-cutting the config.

Thanks Michael for your suggestions - they cleaned the code up a lot.


Need Your Help

SQL row return order

mysql sql-server oracle sqlite postgresql

I have only used SQL rarely until recently when I began using it daily. I notice that if no "order by" clause is used:

Can events fired from an iframe be handled by elements in its parent?

javascript firefox prototypejs

Suppose I have a page located at www.example.com/foo, and it contains an &lt;iframe&gt; with src="http://www.example.com/bar". I want to be able to fire an event from /bar and have it be heard by /...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.