Dynamics 365 quick bites - Solved WCF endpoint configuration exception

Dynamics 365 quick bites - Solved WCF endpoint configuration exception

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.

No alt text provided for this image

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".

No alt text provided for this image

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.

No alt text provided for this image

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
No alt text provided for this image
  • 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
No alt text provided for this image

Hope the above trick will resolve your issue for multiple endpoints binding for service contract. Happy Learning!!


要查看或添加评论,请登录

Ambesh Singh的更多文章

社区洞察

其他会员也浏览了