Search code examples
c#asp.netweb-serviceswcfwcf-binding

Consuming WCF Service Reference: Endpoint not found / 404 page not found


Hi, I know this topic might look familiar to similar topic but I can tell you that it is after an entire day of searching on related issues that I come for help, because none of the suggested solutions has worked for me.

I have created a WCF REST Service Application with only one service that runs locally on my computer as well as a ASP.NET WebForm Client that consumes it (both on individual instance of VS 2013 on a Windows 7).

All the operations of the service work perfeclty fine.

  • GET operations can be successfully tested in the browser
  • POST operations can be successfully tested using Postman browser extension.

Problem: When I try to access this service using a Service Reference on the client such as:

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

the client then throws an EndpointNotFoundException:

There was no endpoint listening at http://localhost:49414/AuthorRESTService.svc that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.

And contains an inner WebException:

The remote server returned an error: (404) Not Found

Here is the partial code of the WCF Service Application server's 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" />

And here's the partial code of the ASP.NET Webform client's 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>

What am I doing wrong? Any help would be much appreciated.


Solution

  • There are three things that stand out to me as possible problems:

    1. In the Web.Config for the WCF application you have<add binding="basicHttpsBinding" scheme="https" /> but the URL in the the client uses "http".
    2. Is the server always running on port 49414?
    3. Are your site's authentication settings correct? Check out EndpointNotFoundException: There was no endpoint listening at.