2

When I add a service reference to a WCF web service in my current ASP.net MVC 3 project, proxy classes are successfully generated, but there's no information added to web.config. This results in an error when I attempt to instantiate the proxy class using the no-args constructor. On this line:

var proxy = new ReportingService.ApiServiceClient();

I get the following runtime exception:

Could not find default endpoint element that references contract 
'ReportingService.IApiService' in the ServiceModel client configuration
section. This might be because no configuration file was found for your
application, or because no endpoint element matching this contract could 
be found in the client element.

This makes sense because there's absolutely nothing in my config file indicating the default endpoint.

What am I missing? Why would adding the service reference fail to create a default endpoint?

Yes - that Jake.
  • 16,725
  • 14
  • 70
  • 96
  • possible duplicate of [Could not find default endpoint element](http://stackoverflow.com/questions/352654/could-not-find-default-endpoint-element) – Rafay Jan 25 '12 at 20:42
  • @3nigma, I doubt this is a dupe because the OP said that he added the service reference to his ASP.NET MVC 3 project. – Darin Dimitrov Jan 25 '12 at 20:43
  • @DarinDimitrov agreed, sry, now i dont know how to revoke the vote to close ... `:|` – Rafay Jan 25 '12 at 20:48
  • There's no way to do it. I've jumped the gun on a few close votes myself. I did check the related pages before posting a new question, though. – Yes - that Jake. Jan 25 '12 at 23:06
  • Its strange that when you add service reference the endpoint information is not added to web.config. Can you retry adding the service reference again and also make sure that your web.config is not read-only or under source control that is preventing it from making modifications. – Rajesh Jan 26 '12 at 10:08
  • I've deleted and regenerated the proxy several times. The problem appears to be a known issue with consuming RESTful services via the default proxy. – Yes - that Jake. Jan 27 '12 at 14:55

0 Answers0