A couple of weeks ago, I thought I’d be clever, or at least act with forethought, and create the Windows Communication Foundation (WCF) service I was working on as four separate interfaces all implemented by the same class.The interfaces would be segmented out by the types that they returned.This would make understanding the code easier down the road and it seemed like a good idea at the time.
However, the goal of this service was to be plugged into Business Connectivity Services (BCS) in SharePoint 2010.It turns out that BCS interacts with WCF services through the SOAP protocol instead of native WCF.In other words, it treats the service as a basic SOAP web service instead of a more capable WCF service.What this means is that multiple interface bindings from the same service, which is what I was doing, do not work correctly in BCS.
Instead, an error is thrown and buried in the SharePoint Front End Web Server log in the SharePoint 2010 hive stating that BCS is unable to unambiguously determine the endpoint of the desired method.However, the BCS model passes validation and initial content type creation.For the most part, if your model validates, it’s likely that it’s semantically correct.
Such was not the case here.Instead, BCS doesn’t read the WSDL, which plainly states that there are multiple bindings for the service.BCS will attempt every method defined for the service with every Line of Business (LOB) instance in the model.
Don’t mistake this for having more than one implementation of the same service.This is entirely possible by creating separate LOB instances to match multiple endpoints.However, each of these endpoints must implement all specified methods.What I was trying to do was implement specific methods for each binding.This is possible by creating multiple LOB system models, but that breaks any associations that may exist between types within the service.
Unfortunately, there’s only one solution: Consolidate all of your service methods into one large interface, which can be messy, but will work every time.Because of how BCS handles WCF you can’t even explicitly create multiple bindings in the web.config of the service.
In summary, you can use multiple endpoints, but you can’t use multiple bindings that don’t all implement all functionality.