此服务的元数据发布目前已禁用 - 再次

时间:2014-01-03 19:24:17

标签: wcf wcf-data-services

我是WCF的新手,过去一周我一直在努力让一切顺利。浏览service.svc文件时,我收到有关未启用元数据的消息。这里有数百个帖子,但我必须遗漏一些东西。我想我正确地遵循了说明,但我仍然找不到我的错误。我哪里错了?任何帮助表示赞赏。

service.svc

<%@ ServiceHost Service="BiteSizeLearningWS.TranscriptService" Debug="true" %>

的web.config

<services>
  <service name="BiteSizeLearningWS.iServiceInterface" behaviorConfiguration="TranscriptServiceBehavior">

    <endpoint address="" binding="basicHttpBinding" contract="BiteSizeLearningWS.TranscriptService" />

    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>

  </service>
</services>

<behaviors>
  <serviceBehaviors>
    <behavior name="TranscriptServiceBehavior">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
    </behavior>
  </serviceBehaviors>
</behaviors>

的ServiceContract

namespace BiteSizeLearningWS
{
    [ServiceContract (Name="TranscriptService")]
    public interface iServiceInterface{...

实施

public class TranscriptService : iServiceInterface

Global.asax中

namespace BiteSizeLearningWS
{
    public class Global : System.Web.HttpApplication
    {

        protected void Application_Start(object sender, EventArgs e)
        {
            RouteTable.Routes.Add(new ServiceRoute("TranscriptService", new WebServiceHostFactory(), typeof(TranscriptService)));  
        }

1 个答案:

答案 0 :(得分:2)

我想你有:

<service name="BiteSizeLearningWS.iServiceInterface"...

名称属性值和

<endpoint address="" ... contract="BiteSizeLearningWS.TranscriptService" />

合同属性值混淆了。试试这个:

<service name="BiteSizeLearningWS.TranscriptService"...

<endpoint address="" ... contract="BiteSizeLearningWS.iServiceInterface" />

如果可行,那么WCF使用服务的自动默认配置值而不是问题中显示的无效配置。默认情况下,元数据端点启用,这就是您看到“已禁用”消息的原因。