As you can guess from recent topics, web services have been a hot issue around here. Whether it’s in the dialplan or the agent scripting, we find that call centers are increasingly looking for live data delivered in real time, and web services are a great way to do this.
Where things do sometimes falter is on initial setup and testing. Hours and hours get spent diagnosing whether an issue is on the remote side or in the way the receiver is interpreting the data. Tests get set up and run, the results are checked, then some incremental change is made and the test run again.
It really doesn’t have to be that complicated.
There are a couple of tools that we use to help cut down the testing and verification time:
1) Just create a file and have it downloaded.
If you’re sending a request and expecting an XML or JSON file with certain fields back, just create a simple valid case in the form of a file. Break out your favourite text editor and write it out. It could be something as simple as:
<response> <field_1>123</field_1> <field_2>ABC</field_2> </response>
Save the file as whatever the response is supposed to be (ie. response.xml). If you have a web server handy (if not, what are you serving the response from?), just place the file somewhere convenient, and have your “web service” return the file. Sometimes you may even be able to encode the URL with the form file:///my-file-path/response.xml and have it read the file in as a web service response. If there’s an error, you either created the file incorrectly (which you can check) or your script isn’t parsing the response correctly.
2) Try hitting the web service with your browser.
You may be able to request a response from the web service, at least on a trial basis, by hitting the right URL in the browser window. It may look odd, but can tell you if you’re getting the response you expected:
You can also use command-line tools like wget if you need to set specific cookies or can only POST requests.
In either case, you may not be able to resolve your problems with your web services right away, but it should make it much clearer where any issues or unexpected behaviour could lie.