In the past few projects, I have found that a lot of 3rd party application still use services references as a means to integrate into their systems. For one, it works very well to add the reference to your development project and work with objects as we are all fond of doing. The disadvantage is that you would need to included the reference to your web.config, when exporting your project from your development environment to production.
A quick fix to this is to always update the web.config file on the server. However, the issue is that you may not always have ready access to the server for whatever reason – the most common being that IT controls access and updates to production environments. Or perhaps you would be able to monitor when changes occur – that your customization would still function. In the event the application does receive updates or the web.config reverts back to the original settings file, the configurations can be added back by re-publishing the customization without having to access the web.config file.
After spending some time, and trolling the internet, there is a way to include web.config changes on our customization, and ensure that when it is published, missing references would always be added.
The first step is to add a customization & bind the project.
When you have bound the project, you will now need to create a class and add the ServiceModel references to your project:
Tip – Add the System.Web.dll, System.ServiceModel.dll & System.Configuration.dll in order to add the references – and don’t forget to add the service reference!
When you have added your DLL & references, you are now able to manage and update your web.config. The sample code here provides a good example:
Lastly, you need to call your code from the plug-in extender you have created:
The full class .cs file would look something like this:
Now, you are able to use the service reference in your code for the required tasks, and the plug-in will take care of deploying the references to the required sites.
I hope you have found this information useful.