Pierre Roudaut
Pierre Roudaut

Reputation: 1073

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.

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.

Upvotes: 1

Views: 6192

Answers (3)

Rajat_RJT
Rajat_RJT

Reputation: 60

Try to add Web Reference of your REST service on client project, it will automatically make some changes to your client web.config and just remove protocol mapping section from your WCF web.config file. This may help you.

Upvotes: 0

Will Lokes
Will Lokes

Reputation: 26

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.

Upvotes: 0

Glumac
Glumac

Reputation: 31

You didn't specify the service endpoint address, you left it blank. Set the address attribute in the endpoint element on the services config file to the same value you set in the clients config. Also, depending how you host your WCF service, you might want to set the service base address.

Upvotes: 1

Related Questions