This chapter describes JavaScript functions and objects that are available to BeVocal VoiceXML applications. These are all extensions to the VoiceXML specification.
For general information on using JavaScript in BeVocal VoiceXML applications, see JavaScript Quick Reference.
Extension. For calls initiated using the Outbound Notification Service, the value of bevocal.outboundrequestid provides the Outbound Request ID associated with the call. This value can be used to map specific application invocations with the request used to initiate the application.
Extension. Provides a unique ID for each call. This value can be used to keep track of call-specific information in the server-side component of your application if cookies cannot be used for any reason.
Extension. Method of a JavaScript SOAP proxy object. Specifies an additional SOAP header for the SOAP service that the proxy object represents.
Once the SOAP header is set on a service object, the SOAP header element is part of the SOAP message for every method executed on that service object.
_addHeader( StringheaderNamespace, StringheaderName, ObjectheaderValue, Stringactor, StringmustUnderstand)
| Parameter | Description |
|
|
|
|
|
|
|
|
|
The value of the |
| | Chapter 10, "SOAP Client Facility" |
You can use the Call Detail Record Access Service to access information about individual calls to a VoiceXML application. You might decide to write another VoiceXML application that presents information retrieved using the CDR service. Because this is a BeVocal platform service, you must pass security information in SOAP request headers to the service.
<script>
var service = bevocal.soap.serviceFromWSDL(
"http://cafe.services.bevocal.com/CDRAccessService_v2/services/CDRAccessServic
e_v2?WSDL",
"CDRAccessService_v2",
"http://www.bevocal.com/soap/services",
"CdrAccessService",
"http://cafe.services.bevocal.com/CDRAccessService_v2/services/CDRAccessServic
e_v2"
);
service._addHeader(
"http://www.bevocal.com/soap/headers/",
"platformServicesSessionID",
"ACB035CB-C307-472e-99BA-3D5B8468BB76");
...
</script>
After the call to _addHeader, SOAP headers using that proxy object would include this information:
<soapenv:Header>
<ns1:platformServicesSessionID
xsi:type="xsd:string"
xmlns:ns1="http://www.bevocal.com/soap/headers/" >
ACB035CB-C307-472e-99BA-3D5B8468BB76
</ns1:platformServicesSessionID>
</soapenv:Header>
Extension.Sets a cookie on the VXML client. The created cookie is treated as HTTP cookies and is passed over the subsequent fetches in the application. The cookie lasts for the duration of the call or the session.
bevocal.cookies.addClientCookie( Stringdomain, Stringkey, Stringvalue, )
| Parameter | Description |
|
If a valid domain is passed, the created cookie is passed as a HTTP header for subsequent fetches matching the same domain. |
|
|
|
| | bevocal.cookies.deleteClientCookie |
| | bevocal.cookies.getClientCookie |
| | bevocal.cookies.getClientCookies |
This example demonstrates the bevocal.cookies.addClientCookie, bevocal.cookies.deleteClientCookie, bevocal.cookies.getClientCookie, and bevocal.cookies.getClientCookies methods.
Note that the first two cookies are sent as HTTP cookies because the domain parameter is set to cafe.bevocal.com.
<!-- clientcookies.vxml -->
<?xml version="1.0" encoding="iso-8859-1"?>
<vxml version="2.0" xmlns="http://www.w3.org/2001/vxml"
xmlns:bevocal="http://www.bevocal.com/">
<var name="user_1"/>
<var name="user_2"/>
<var name="user_3"/>
<var name="user"/>
<form id="form1">
<block>
<prompt>Testing client cookies</prompt>
<script>
bevocal.log("setting cookies now");
bevocal.cookies.addClientCookie("cafe.bevocal.com", "user_1", "1234");
bevocal.cookies.addClientCookie("cafe.bevocal.com", "user_2", "hello world");
bevocal.cookies.addClientCookie(null, "user_3", "xyz123");
user_1 = bevocal.cookies.getClientCookie(null, "user_1");
user_2 = bevocal.cookies.getClientCookie(null, "user_2");
user_3 = bevocal.cookies.getClientCookie(null, "user_3");
bevocal.log("user_1 = " + user_1 + "; user_2 = " + user_2 + "; user_3 = " +
user_3);
user = bevocal.cookies.getClientCookies(null);
bevocal.log("The value from map is " + user.get("user_1"));
</script>
</block>
<block>
<prompt><value expr="user_1"/><value expr="user_2"/><value expr="user_3"/>
</prompt>
<goto next="clientcookies_2.vxml"/>
</block>
</form>
</vxml>
<!-- clientcookies 2.vxml -->
<?xml version="1.0" encoding="iso-8859-1"?>
<vxml version="2.0" xmlns="http://www.w3.org/2001/vxml"
xmlns:bevocal="http://www.bevocal.com/">
<var name="user_2"/>
<form id="form1">
<block>
<prompt>Testing client cookies in second document </prompt>
<script>
user_2 = bevocal.cookies.getClientCookie(null, "user_2");
bevocal.log("user_2 = " + user_2);
bevocal.cookies.deleteClientCookie("user_2");
</script>
</block>
<block>
<prompt><value expr="user_2"/></prompt>
<goto next="clientcookies_3.vxml"/>
</block>
</form>
</vxml>
<!-- clientcookies_3.vxml -->
<?xml version="1.0" encoding="iso-8859-1"?>
<vxml version="2.0" xmlns="http://www.w3.org/2001/vxml"
xmlns:bevocal="http://www.bevocal.com/">
<var name="user_2"/>
<var name="user_3"/>
<form id="form1">
<block>
<prompt>Testing client cookies in third document </prompt>
<script>
user_2 = bevocal.cookies.getClientCookie(null, "user_2");
user_3 = bevocal.cookies.getClientCookie(null, "user_3");
bevocal.log("user_2 = " + user_2 + "; user_3 = " + user_3);
</script>
</block>
<block>
<prompt><value expr="user_2"/><value expr="user_3"/></prompt>
</block>
</form>
</vxml>
Extension.Deletes a cookie on the VXML client.
bevocal.cookies.deleteClientCookie( Stringdomain, Stringkey, )
| Parameter | Description |
|
If a valid domain is passed, a cookie with name key that matches the domain is deleted. Otherwise, a cookie with that name is deleted. |
|
| | bevocal.cookies.addClientCookie |
| | bevocal.cookies.getClientCookie |
| | bevocal.cookies.getClientCookies |
See bevocal.cookies.addClientCookie
Extension. Gets the value of a cookie.
bevocal.cookies.getClientCookie( Stringdomain, Stringkey, )
| Parameter | Description |
|
If a valid domain is passed, a cookie with name key that matches the domain is returned. Otherwise, a cookie with that name is returned. |
|
| | bevocal.cookies.addClientCookie |
| | bevocal.cookies.deleteClientCookie |
| | bevocal.cookies.getClientCookies |
See bevocal.cookies.addClientCookie
Extension. Returns a HashMap of all key/value cookie pairs.
bevocal.cookies.getClientCookies(
String domain,
)
| Parameter | Description |
|
If a valid domain is passed, cookies matching that domain are returned. Otherwise, all cookies are returned. |
| | bevocal.cookies.addClientCookie |
| | bevocal.cookies.deleteClientCookie |
| | bevocal.cookies.getClientCookie |
See bevocal.cookies.addClientCookie
Extension. The BeVocal VXML Interpreter decrypts the text (in HEX format) using the private key using the RSA/ECB/OAIPPadding algorithm. This public/private encryption has been tested with Bouncy Castle's implementation of JCE. The decrypted text is returned in clear text.
bevocal.decrypt( Stringtext, String privateKey, )
| Parameter | Description |
|
|
|
| | bevocal.encrypt |
Extension. The BeVocal VXML Interpreter encrypts the text using this public key using the RSA/ECB/OAIPPadding algorithm. This public/private encryption has been tested with Bouncy Castle's implementation of JCE. The encrypted text is returned in HEX format.
bevocal.encrypt( Stringtext, String publicKey, )
| Parameter | Description |
|
|
|
| | bevocal.decrypt |
Extension. Deletes enrolled phrases from grammars.
bevocal.enroll.removeEnrolledPhrase(grammar,speakerid,phraseid,key,xml:lang)
If you are using enrollment to maintain a voice address book or other dynamic lookup mechanism, you need to be able to delete phrases from the grammar in addition to adding them.
Extension. Gets the value of a VoiceXML property.
bevocal.getProperty(String name)
| Parameter | Description |
|
The value of the specified property in the current scope.
Extension. Returns the VoiceXML interpreter version.
bevocal.getVersion()
The version number of the VoiceXML interpreter, as a string. Currently, this function always returns "2.4".
Extension. Writes a message to the BeVocal Café website.
bevocal.log(String message)
| Parameter | Description |
|
The log function writes the specified message to the BeVocal Café call log, which you can view on the Café website. This function performs the same operation as a <log> VoiceXML element with no label or expr attribute.
Extension. Method of the bevocal.soap object. Given the URL for a WSDL file, create an object to act as a proxy for one of the services described in the file.
This is the preferred way to create a service proxy object. The WSDL file allows the interpreter to pre-load the proxy object with information about all of the service's methods and their parameter types, making the mapping from JavaScript types to SOAP encodings much more accurate.
bevocal.soap.serviceFromWSDL( StringWSDLUrl, Stringport, StringsvcNamespace, StringsvcName, StringendpointURL)
If an error occurs while locating a SOAP service or creating a SOAP proxy object, an exception of type bevocal.soap.SoapException will be thrown. Possible errors include:
| | Receives a malformed URL. |
| | Cannot open a network connection or retrieve a resource. |
| | Referenced WSDL file is malformed or does not contain the requested service or port. |
| | Chapter 10, "SOAP Client Facility" |
Extension. Method of the bevocal.soap object. Given the name and endpoint URL of a SOAP service, create an object to act as a proxy for the service. This method should be used only when the WSDL for a service is not available, since the proxy it creates does not have information on method names and parameter types available, and thus has to make more assumptions when it makes SOAP method calls.
bevocal.soap.serviceFromEndpoint( StringendpointURL, StringsvcNamespace, StringsvcName)
| Parameter | Description |
|
|
|
|
|
If an error occurs while locating a SOAP service or creating a SOAP proxy object, an exception of type bevocal.soap.SoapException will be thrown. Possible errors include:
| | Receives a malformed URL. |
| | Cannot open a network connection or retrieve a resource. |
| | Referenced WSDL file is malformed or does not contain the requested service or port. |
| | Chapter 10, "SOAP Client Facility" |
To use a temperature service available from www.xmethods.net, go there and see that the WSDL for this service is at http://www.xmethods.net/sd/2001/TemperatureService.wsdl. The content of the WSDL is:
<?xml version="1.0"?>
<definitions name="TemperatureService"
targetNamespace="http://www.xmethods.net/sd/TemperatureService.wsdl"
xmlns:tns="http://www.xmethods.net/sd/TemperatureService.wsdl"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns="http://schemas.xmlsoap.org/wsdl/">
<message name="getTempRequest">
<part name="zipcode" type="xsd:string"/>
</message>
<message name="getTempResponse">
<part name="return" type="xsd:float"/>
</message>
<portType name="TemperaturePortType">
<operation name="getTemp">
<input message="tns:getTempRequest"/>
<output message="tns:getTempResponse"/>
</operation>
</portType>
<binding name="TemperatureBinding" type="tns:TemperaturePortType">
<soap:binding style="rpc"
transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="getTemp">
<soap:operation soapAction=""/>
<input>
<soap:body use="encoded" namespace="urn:xmethods-Temperature"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body use="encoded" namespace="urn:xmethods-Temperature"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
</binding>
<service name="TemperatureService">
<documentation>Returns current temperature in a given U.S. zipcode
</documentation>
<port name="TemperaturePort" binding="tns:TemperatureBinding">
<soap:address
location="http://services.xmethods.net:80/soap/servlet/rpcrouter"/>
</port>
</service>
</definitions>
The bold lines in the defintion provide the rest of the information you need to create a proxy object for this service in your VoiceXML application:
<script>
<![CDATA[
var service =
bevocal.soap.serviceFromWSDL(
// WSDL URL
"http://www.xmethods.net/sd/2001/TemperatureService.wsdl",
// name attribute of port
"TemperaturePort",
// targetNamespace attribute of definitions
"http://www.xmethods.net/sd/TemperatureService.wsdl",
// name attribute of service
"TemperatureService",
// location attribute of soap:address child of port element
"http://services.xmethods.com:80/soap/servlet/rpcrouter" //
);
]]>
</script>
Extension. Method of the bevocal.soap object. Uses the BeVocal SOAP service registry to locate either the standard BeVocal SOAP service whose id is serviceId or a particular version of that service. Returns a proxy object that can be used to call its methods.
Currently, there are not services in the BeVocal SOAP service registry.
bevocal.soap.locateService( StringserviceId, Stringversion)
If an error occurs while locating a SOAP service or creating a SOAP proxy object, an exception of type bevocal.soap.SoapException will be thrown. Possible errors include:
| | Chapter 10, "SOAP Client Facility" |
Extension. Exception object. If an error occurs while creating a SOAP proxy object, an exception of type bevocal.soap.SoapException will be thrown. This object has two dynamic properties and a number of constants:
<script>
var service;
try {
service = bevocal.soap.locateService("myservice", "2.0");
}
catch (error if error.type == "bevocal.soap.SoapException") {
if (error.cause == error.BAD_VERSION) {
service = bevocal.soap.locateService("myservice", "1.0");
} else {
throw error;
}
}
</script>
If the exception is not caught in JavaScript code in the <script>, it will propagate to the VoiceXML interpreter and be re-thrown as an error.semantic in VoiceXML.
| | Chapter 10, "SOAP Client Facility" |
Extension. Fault object. This object has the following properties:
| | Chapter 10, "SOAP Client Facility" |
Extension. FaultDetails object. Essentially, bevocal.soap.FaultDetails is an object whose property names are the local components (without namespaces) of the names of the elements under the details element, and whose property values are the text contents of those elements.
| | Chapter 10, "SOAP Client Facility" |
| Café Home |
Developer Agreement |
Privacy Policy |
Site Map |
Terms & Conditions Part No. 520-0001-02 | © 1999-2007, BeVocal, Inc. All rights reserved | 1.877.33.VOCAL |