UPDATE - 17th November 2015
Add Service Widget - 1.2
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).
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
UPDATE - 19th June 2015
Add Service Widget - 1.1.3
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.
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
UPDATE - 16th June 2015
Add Service Widget - 1.1.1
Fixed Layer List bug (where layer list showed map services as layer1, layer2 etc.). Layer list widget will now read in the json.mapName object for dynamic and tiled map services.
Add Service Widget - 1.1
Stan McShinsky has added code to the settings folder to enable automatic integration with web app builder. Just unzip the widget and drop it into your web app builder stemapp "Widgets" folder.
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
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!).
Instructions
To add to your Web App Builder application, extract the zipped AddService folder and paste it into your application's "widgets" folder.