I am trying to swap configuration files in and out of my web api to interact with different WCF webservices. I found the solution to change my webconfig files at run time in the following link.
This works great when called from a command line application substituting in my new configuration file but when i call the config file changer from my API I Get the following Error.
"Could not find default endpoint element that references contract 'OldDominionWebServices.RateDelegate' 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 is the endpoint I am trying to reference
<endpoint address="https://www.odfl.com:443/wsRate_v4/RateService" binding="basicHttpBinding" bindingConfiguration="RatePortBinding" contract="OldDominionWebServices.RateDelegate" name="OldDominionWebServices" />
I know what the error says, but am unsure as to why this would be thrown in a web api with the configuration file swapped, but not thrown when using a console application that does the same thing. In the case of the command line app the assembly that uses this web service is referenced as part of the solution, where as with the api the assembly is loaded via reflection. I have seen some suggestions that I need to use the Fully qualified domain name in the contract for the endpoint, but this still results in the same error.
I'm hoping this is something simple that I have overlooked, Thanks in advance!