Monday, April 6, 2015

specify a WCF endpoint in C# while keeping the bindings in Web.config

You may keep both the bindings and the endpoint for a web service in Web.config and then in C# overpower what address the endpoint uses like so:

ICalculatorInTheSky calculator = new CalculatorInTheSkyClient("MyEndpointName",
      "https://www.example.com/hellothere");

 
 

This shows how this may be revamped so that the binding stuff doesn't have to live on the C# side which is way painful configure. If you want to have a Service Reference in a project that is not the startup project, you'll need to move the bindings and endpoint which appear in that projects app.config (which didn't exist until just now) to Web.config. Freak.

No comments:

Post a Comment