使用WCF服务参考:未找到端点/ 404页面未找到

时间:2015-04-08 03:35:59

标签: c# asp.net web-services wcf wcf-binding

嗨,我知道这个主题在类似主题上可能看起来很熟悉,但我可以告诉你,经过一整天的搜索相关问题,我来寻求帮助,因为没有一个建议的解决方案适用于我

我创建了一个 WCF REST服务应用程序,只有一个在我的计算机上本地运行的服务以及一个消耗它的 ASP.NET WebForm客户端(两者都在Windows 7上的VS 2013的单个实例。

服务的所有操作都完好无损。

  • GET 操作可以在浏览器中成功测试
  • 可以使用Postman浏览器扩展程序成功测试
  • POST 操作。

问题:当我尝试使用客户端上的服务参考来访问此服务时,例如:

AuthorRESTServiceClient service = new AuthorRESTServiceClient("AuthorServiceBinding");
string value = service.Test(); //GET operation that should return a "Hello World"

然后客户端抛出EndpointNotFoundException

  

没有终点收听   http://localhost:49414/AuthorRESTService.svc可以接受   信息。这通常是由错误的地址或SOAP操作引起的。   有关更多详细信息,请参阅InnerException(如果存在)。

并包含内部WebException

  

远程服务器返回错误:(404)Not Found

以下是 WCF服务应用服务器 Web.config 的部分代码:

  <system.serviceModel>
    <services>
      <service name="WCFAuthorEntryService.AuthorRESTService">
        <endpoint address=""
                  binding="webHttpBinding"
                  contract="WCFAuthorEntryService.IAuthorRESTService"
                  behaviorConfiguration="web">
        </endpoint>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="web">
          <webHttp/>
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <protocolMapping>
      <add binding="basicHttpsBinding" scheme="https" />
    </protocolMapping>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />

此处是 ASP.NET Webform 客户端 Web.config

的部分代码
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="AuthorServiceBinding"/>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://localhost:49414/AuthorRESTService.svc"
                binding="basicHttpBinding"
                bindingConfiguration="AuthorServiceBinding"
                contract="AuthorServiceReference.IAuthorRESTService"
                name="AuthorServiceBinding"/>
    </client>
  </system.serviceModel>

我做错了什么?任何帮助将不胜感激。

3 个答案:

答案 0 :(得分:1)

您没有指定服务端点地址,而是将其留空。将服务配置文件中address元素中的endpoint属性设置为您在客户端配置中设置的相同值。此外,根据您托管WCF服务的方式,您可能需要设置服务基地址。

答案 1 :(得分:1)

作为可能出现的问题,有三件事可以突显出来:

  1. 在WCF应用程序的Web.Config中,您有<add binding="basicHttpsBinding" scheme="https" />,但客户端中的URL使用&#34; http&#34;。
  2. 服务器是否始终在端口49414上运行?
  3. 您的网站的身份验证设置是否正确?查看EndpointNotFoundException: There was no endpoint listening at

答案 2 :(得分:0)

尝试在客户端项目上添加REST服务的Web引用,它将自动对您的客户端web.config进行一些更改,并从WCF web.config文件中删除协议映射部分。这可能会对你有帮助。

相关问题