Base solution for your next web application
Open Closed

Service Reference in Preinitialise #4626


User avatar
0
OriAssurant created

I am consuming a WCF Service in .Application project. To achieve the same, I have specified system.serviceModel configuration in app.config(.Application project) and Web.config(.Web project)

Now, I want to remove the syste.serviceModel from the config and be able to derive endpoint from the database leveraging settings.

I did the following:

  1. Remove system.serviceModel from App.config
  2. Place the below code in Preinitialise method of MajesticApplicationModule: String baseAddress = "This will come from SettingManager"; BasicHttpBinding binding = new BasicHttpBinding(); using (ServiceHost host = new ServiceHost(typeof(ServiceClient))) { host.AddServiceEndpoint(typeof(IService), binding, baseAddress); }
  3. Remove system.serviceModel from Web.config
  4. Place the code from step 2 in Preinitialize method of MajesticWebModule

After making these changes, I am getting the below error:

Could not find default endpoint element that references contract 'UserService.IOktaService' 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.

Is there something I am missing? Please point me in the right direction.


No answer yet!