Dynamics 365 quick bites - Solved WCF endpoint configuration exception
Ambesh Singh
Dynamics 365 CE Architect | Azure | Power Platform | Power Pages & Microsoft Copilot Studio MVP (MCP | MCTS | MCSA | MCSE)
When you add a web reference of wsdl to a console or service projects, it works a little differently, while creating a "service" reference. This may cause some problems with web services that have more than one binding, i.e. designed to support Soap 1.0 and Soap 1.2.
This fix explained here is helpful if you are using WCF and when you try to access the service, the client throws an exception like "An endpoint configuration section for contract ‘xxx' could not be loaded because more than one endpoint configuration for that contract was found. Please indicate the preferred endpoint configuration section by name".
WCF service can expose more than one endpoint and client can use any of this endpoint but not more than one at a time. This type of exception occurs when you have more than one endpoint configured at your configuration file (app.config) file while adding service reference or while configuring service at client side manually. You can have only one and only endpoint for the client.
Resolution - This was the first sign of this nasty quirk; you may resolve the issue by one of two way-
- If you are getting this exception then check your client side configuration file and make sure the client tag under system.serviceModel has only one endpoint configured. So remove additional endpoint binding from web or app config file under system.serviceModel -> client tag like image below
- The above solution is not much feasible in some situation, As a second option, you can pass the endpoint name as a parameter sent to the constructor like image below
Hope the above trick will resolve your issue for multiple endpoints binding for service contract. Happy Learning!!