1

How I can call webservice from voice xml (vxml) document. I am using an opensource IVR project and I need to run a webservice for any given option from within the vxml document.

This is similar to this query; how can I call a webservice from voiceXML? However, solution is provided there but it is not

Community
  • 1
  • 1
M kapil
  • 21
  • 1

2 Answers2

1

You cannot call a web service directly from a VoiceXML application. There are generally two approaches for getting data into a VoiceXML application:

  1. Use the data element tag to make an http request. The result must be XML. You will need to parse the result with the provided DOM functions. Note, some browsers have extended features to facilitate XML parsing. This also requires a VoiceXML 2.1 compliant browser.
  2. Transfer control to a dynamic bit of server code that returns VXML to be processed populating your desired variables. This can be done with a goto element or subdialog element.
Jim Rush
  • 4,143
  • 3
  • 25
  • 27
  • Thanks for the help. I am even in elementary phase - I suspect my open IVR system doesn't recognize 'data', 'src' elements in vxml. I use 'data' element in the vxml document with a url given in 'src' value. My open IVR (Zanzibar) system doesn't recognize it and throws an exception on its console, caught JVoiceXML event while processing org.jvoicexml.event.error.BadFetchError: error.badfetch: Exactly one of 'src' or 'srcexpr' must be specified .... – M kapil Aug 03 '15 at 11:43
  • JVoiceXML does support the data element (I'm using the codebase for a testing project). srcexpr might have been missing implementation logic. I vaguely remember having to fix it. Insure a recent version of JVoicexml is being used. – Jim Rush Aug 03 '15 at 14:59
1

Your question is incomplete, but I suspect I know what's bothering you.

I get information from a webservice by using

<data name="return_data" srcexpr="some_url" method="post" namelist="var1 var2 var3" />

The data I get back is inside the return_data variable. In my case, the data are in XML format, and I use JavaScript functions to extract the data I need.

As an aside, for maintainability, re-usability, and ease of reading, I personally find it useful to create separate files for the JS functions and include them via <script> into my root VoiceXML document.