This blog explains how to call external Web Service from a CRM 2011 Plug-in.
Sometimes we need to call a Web Service from a Plug-in. We had a similar requirement, but while trying to access the service, we got the following error.
“Could not find default endpoint element that references contract ‘ServiceReference.Service′ 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.”
The reason for this is because the configuration information for the Web Service from the client side is missing.
Using the Code
So, now in case of our plugin, we need to define the binding and endpoint information programmatically. Something like this…
This way we would be able to access our Web Service inside Plug-in.