Cisco Cisco Customer Voice Portal 8.0(1) Guida Dello Sviluppatore

Pagina di 122
String addXmlBody(VMain vxml, Hashtable params, 
            VoiceElementData data) throws VException, ElementException
This is the execution method for voice elements. The arguments to the method are:
vxml – The 
VMain
 object is the container VFC object in which all VoiceXML content is
added (by adding other VFC objects to it). The desired VoiceXML page to produce must be
assembled using the VFCs and added to this object. If no VFCs are added, an incomplete
VoiceXML page will be produced, causing the voice browser to encounter an error. Simply
add all 
VForm
 objects to this object. VXML Server will take care of the rest.
Note: The form you wish to be visited first must be named startThis is very important!
params – The 
params
 object is a 
Hashtable
 that contains all HTTP arguments passed by
the voice browser through VXML Server. For example, if the voice element produces a
VoiceXML page with a variable named dataToCollect that is then included in a submit
argument list, the 
params Hashtable
 will contain an entry with the key dataToCollect
and the value as a 
String
. To access it, the developer would write:
String data = (String) params.get("dataToCollect");
data – The 
VoiceElementData
 object belongs to the Session API and is used to access
session information (See 
 for more information on this API). Aside
from the standard functionality, 
VoiceElementData
 provides all data required by the voice
element such as ways to access the scratch space, obtain the 
VPreference
 object used to
instantiate the VFCs, and obtain the voice element’s configuration object,
VoiceElementConfig
.
The 
String
 return value of the method must refer to the real name of the voice element’s exit
state. The real name of the exit state must match one of the names given in the
getExitStates()
 configuration method. Since voice elements can span multiple VoiceXML
pages, returning 
null
 indicates that the voice element is not done and the execution method
should be visited again when the voice browser sends its next request to VXML Server. Only
when the method returns a proper exit state will VXML Server follow the application call flow
and proceed to the next element. The method throws an 
ElementException
 that is used to
indicate an error occurred within the execution method that prevented the voice element from
doing its assigned task. The error message will be logged in the application’s error log and the
error element (if applicable) will be visited. This method additionally throws a 
VException
,
which is generated by incorrectly configured VFCs and does not need to be thrown explicitly
by the element execution method itself.
Utility Methods
String getSubmitURL()
One of the restrictions listed for creating a voice element is to use a Unified CVP-specified
URL when submitting back to VXML Server. This method returns the URL to use. The
developer would use this URL in a 
<submit>
 adding any arguments desired.
VAction getSubmitVAction(String args, VPreference pref)
Programming Guide for Cisco Unified CVP VXML Server and Cisco Unified Call Studio Release 8.0(1)
64
Chapter 9: Configurable Elements
Voice Elements