rboarman
rboarman

Reputation: 8214

How to expose metadata using WCF's new simplified config model

I have a simple WCF4 REST service which is working fine when using a browser. However, when I try to add a service reference to it from another project in VS2010, I get an error saying that, “The HTML document does not contain Web service discovery information.”

My question is, since WCF4 has a new simplified config model, I can’t find any working examples of how to turn on a metadata exchange endpoint for the currently exposed standard endpoint.

I tried adding a entry as shown below but it did not solve the problem.

Here’s my config:

<system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
    <standardEndpoints>
      <webHttpEndpoint>
        <!-- 
            Configure the WCF REST service base address via the global.asax.cs file and the default endpoint via the attributes on the <standardEndpoint> element below
        -->
        <standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true"/>

      </webHttpEndpoint>
      <mexEndpoint>
        <standardEndpoint name=""/>
      </mexEndpoint>

    </standardEndpoints>
  </system.serviceModel>

Any assistance would be greatly appreciated.

Rick

Upvotes: 2

Views: 4941

Answers (1)

Ladislav Mrnka
Ladislav Mrnka

Reputation: 364369

Metadata endpoints expose WSDL + XSDs which describes SOAP services. There is no support for exposing metadata for REST. WCF does not support WADL (description of REST services).

If you need to add metadata to SOAP service with simplfied configuration you need to add this behavior:

<configuration>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

Upvotes: 4

Related Questions