【问题标题】:WCF Error 404 - Possibly the config fileWCF 错误 404 - 可能是配置文件
【发布时间】:2013-08-21 22:50:17
【问题描述】:

我创建了一个 WCF 项目并且我正在使用 WCF 测试客户端,我收到了返回的消息。但是,当我使用浏览器访问端点地址时,我收到了错误 404。我的代码如下所示:

[WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json, UriTemplate = "UpdateTbl/{tblName}")]
public string UpdateTbl(string tblName)
{ ... }

配置文件中的相关代码如下:

<system.serviceModel>
  <services>
         <service name="WcfJsonRestService.Service1" >
<endpoint address="http://thehost:47423/Service1" binding="webHttpBinding" contract="WcfJsonRestService.IService1" >
</endpoint>
         </service>
     </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>

      <endpointBehaviors>
            <behavior name="webHttp">
                <webHttp helpEnabled="true" automaticFormatSelectionEnabled="true"/>
            </behavior>
      </endpointBehaviors>
    </behaviors>

    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>

如果您能分享您的经验,请提供帮助。谢谢。

【问题讨论】:

    标签: wcf


    【解决方案1】:

    您无法通过提供端点 URL 来配置服务激活。您用于端点元素的语法适用于客户端配置文件,而不是服务。您必须使用 SVC 文件的 URL 进行激活,或者使用更复杂的激活方案,如 herehere 所述。

    【讨论】:

    • 感谢您的反馈。作为 WCF 中的新手,我仍然不清楚配置。我检查了您提供的 2 个地址,并尝试使用那里的语法,但出现了一些额外的错误。如果您能提供一个更简单/更好的示例的 URL,我将不胜感激。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-24
    • 2012-08-31
    • 1970-01-01
    • 2023-03-21
    • 1970-01-01
    • 2019-12-28
    • 1970-01-01
    相关资源
    最近更新 更多