1

I have:

  1. WCF Service [Application 1]
  2. Logic communicating with this service [Project1 Application2]
  3. Web Page using this logic [Project2 Application2]

In Logic project I added service reference to Service. In WebPage I added project reference to Logic.

Now endpoints to Service are definied in Logic project so I cannot connect to Service from WebPage.

I know that I solution is to copy part of Logic config to WebPage config, but I don't think it's a good solution.

I would like to have Logic as a black box. I don't know if I wouldn't change it to another service, maybe something different, so I don't want to WebPage "know" how Logic works.

Is there any better solution? Something I could do in Logic project which would make WebPage know how to connect to Service?

I'm getting exception: Could not find default endpoint element that references contract

Ari
  • 3,101
  • 2
  • 27
  • 49

1 Answers1

1

The other option is to configure Logic by placing the endpoints in the code instead of the configuration file. When you create your web service client, use this overload, which takes a Binding and EndpointAddress as parameters. In the code of your Logic class, just supply those parameters in the code instead of letting it read them automatically from the config file.

Tim Copenhaver
  • 3,282
  • 13
  • 18
  • It's better for me, but I would rather have sth in config. I'd like to (if possible) change endpoint without recompiling – Ari Sep 24 '12 at 16:01
  • I'm not sure I'm following...if you want to put it in a config file, why not just put it in the WebApp.config file? You could also just leave it in the config file for Logic. Then when you want to create your client, just read the Logic config file manually and extract the endpoint and binding data you need, so you can pass them into the client constructor. – Tim Copenhaver Sep 24 '12 at 16:27