WCF Restful 服务停止工作

WCF Restfull service stopped working

在更改服务的命名空间之前,我的这项服务一直运行良好。还更改了项目中的默认命名空间。我遇到了一些关于不发布元数据的错误,所以我撤消了我的更改,但没有任何效果。我什至创建了一个新服务来测试它是否再次运行,而不是在我尝试测试我的休息服务时收到 http 400。这已经是漫长的一周了,我已经精疲力尽了。谁能看出我在这里做错了什么?

更新:http 400 不见了,这是我的错误 seeing:Error:无法从 http://localhost:1585/ProdSvc.svc 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

获取元数据
[OperationContract]
void DoWork();

[OperationContract]
   [WebInvoke(Method = "GET", 
       ResponseFormat = WebMessageFormat.Xml,
       BodyStyle = WebMessageBodyStyle.Bare, 
   UriTemplate = "GetProductName/")]
   string GetProductName();

public string GetProductName()
{
    return "It worked!!!";
}

<system.serviceModel>
    <services>
      <service name="TSServices.ProdSvc" behaviorConfiguration="serviceBehavior">
        <endpoint address=""
                               binding="webHttpBinding"
                               contract="TSServices.ProdSvc"
                              behaviorConfiguration="web"></endpoint>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="serviceBehavior">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="web">
          <webHttp/>
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>

Supertopi 的回答是正确的。添加配置部分就可以了。