Widget updated with WMS functionality. Apologies for how long this took, but it was quite a complex task. I finally found a workflow I was happy with, that would also support non-ESRI WMS. This widget cannot handle secured WMS.
The widget requires some configuration in the config.json file. It is an array of the GIS servers that you will be adding web services from. The code handles this and pushes them as corsEnabledServers. If the server isn't CORS enabled, I believe it won't permit adding of the service in your application.
A change was added to the image service workflow, whereby if the image service is cached it will bring it in as a tiled map service rather than an image service, as the image service capability limits the amount of tiles viewable (defined in the service).
Fixed image service bug. Added additional code for error handling.
Add Service Widget - 1.1.2
Fixed image service bug. Now checks for the allowRasterFunction in JSON object to infer image service type, and attributes a new variable called imageServiceBool depending on outcome. If the allowRasterFunction object exists in the JSON then imageServiceBool = true, else imageServiceBool = false.
This widget will add an ArcGIS Server service at run time to web app builder. It currently accepts Dynamic and Tiled Map Services, and Image Services. The widget has been designed to handle secured services.
Added services can be controlled in the layer list widget (thanks to its listeners!).
To add to your Web App Builder application, extract the zipped AddService folder and paste it into your application's "widgets" folder.