【问题标题】:WCF Restfull service stopped workingWCF Restful 服务停止工作
【发布时间】:2015-01-31 01:19:23
【问题描述】:

在我更改服务的命名空间之前,我的这项服务运行良好。还更改了项目中的默认命名空间。我遇到了一些关于不发布元数据的错误,所以我撤销了我的更改,但并非没有任何效果。我什至创建了一个新服务来测试让这个再次运行,而不是当我尝试测试我的休息服务时我得到一个 http 400。这是漫长的一周,我完全把头发拉出来了。谁能看到我在这里做错了什么?

更新:http 400 消失了,这是我看到的错误:错误:无法从http://localhost:1585/ProdSvc.svc 获取元数据如果这是您有权访问的 Windows (R) Communication Foundation 服务,请检查您是否拥有在指定地址启用元数据发布。有关启用元数据发布的帮助,请参阅 http://go.microsoft.com/fwlink/?LinkId=65455 上的 MSDN 文档

[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>

【问题讨论】:

标签: wcf rest


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-09-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-29
    • 1970-01-01
    相关资源
    最近更新 更多