C# - WCF - 无法添加服务。可能无法访问服务元数据

时间:2015-04-03 21:00:52

标签: c# wcf metadata

我正在尝试调试我的项目,我收到此错误:“无法添加服务。可能无法访问服务元数据。请确保您的服务正在运行并公开元数据”。我对我的IService类进行了一些小改动,现在报告了这个错误。这是我的配置文件:

<?xml version="1.0"?>
<configuration>
  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true"/>
  </appSettings>
  <!--
    For a description of web.config changes see http://go.microsoft.com/fwlink/?LinkId=235367.

    The following attributes can be set on the <httpRuntime> tag.
      <system.Web>
        <httpRuntime targetFramework="4.5.1" />
      </system.Web>
  -->
  <system.web>
    <compilation debug="true" targetFramework="4.5.1"/>
    <httpRuntime targetFramework="4.5"/>
  </system.web>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="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>
    <protocolMapping>
      <add binding="basicHttpsBinding" scheme="https"/>
    </protocolMapping>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
    <!--
        To browse web app root directory during debugging, set the value below to true.
        Set to false before deployment to avoid disclosing web app folder information.
      -->
    <directoryBrowse enabled="true"/>
  </system.webServer>
</configuration>

这是我的IService文件:

[ServiceContract]
public interface IBoggleService
{
    // POST - /makeuser
    [OperationContract]
    [WebInvoke(Method = "POST",
        UriTemplate = "/makeuser/{nickname}",
        RequestFormat = WebMessageFormat.Json,
        ResponseFormat = WebMessageFormat.Json,
        BodyStyle = WebMessageBodyStyle.Bare)]
    string MakeUser(string nickname);

    // POST - /joingame
    [OperationContract]
    [WebInvoke(Method = "POST",
        UriTemplate = "/joingame/{userToken}",
        RequestFormat = WebMessageFormat.Json,
        ResponseFormat = WebMessageFormat.Json,
        BodyStyle = WebMessageBodyStyle.Bare)]
    string JoinGame(string userToken);

    // DELETE - /joingame
    [OperationContract]
    [WebInvoke(Method = "DELETE",
        UriTemplate = "/joingame/{userToken}/{gameToken}",
        RequestFormat = WebMessageFormat.Json,
        ResponseFormat = WebMessageFormat.Json,
        BodyStyle = WebMessageBodyStyle.Bare)]
    void DeleteGame(string userToken, string gameToken);

    // GET - /status?gameToken=string
    [OperationContract]
    [WebInvoke(Method = "GET",
        UriTemplate = "/status?gameToken={gameToken}",
        RequestFormat = WebMessageFormat.Json,
        ResponseFormat = WebMessageFormat.Json,
        BodyStyle = WebMessageBodyStyle.Bare)]
    GameStatus GameStatus(string gameToken);

    // GET - /briefstatus?gameToken=token
    [OperationContract]
    [WebInvoke(Method = "GET",
        UriTemplate = "/briefstatus?gameToken={gameToken}",
        RequestFormat = WebMessageFormat.Json,
        ResponseFormat = WebMessageFormat.Json,
        BodyStyle = WebMessageBodyStyle.Bare)]
    GameBriefStatus GameStatusBrief(string gameToken);

    // POST - /playword
    [OperationContract]
    [WebInvoke(Method = "POST",
        UriTemplate = "/playword",
        RequestFormat = WebMessageFormat.Json,
        ResponseFormat = WebMessageFormat.Json,
        BodyStyle = WebMessageBodyStyle.Bare)]
    WordScore PlayWord(Word word);
}

我做错了什么?

0 个答案:

没有答案