<nuance:send>
This element is a Nuance extension. Use it to send data to a server or a file system without transitioning to a new VoiceXML document.
The usage is similar to the <data> element, except that it posts data in one direction. (The server cannot return information.)
Attributes
This section describes the attributes you can set for this element.
|
Name |
Data type |
Default |
|---|---|---|
|
(true | false) |
true |
|
|
URI |
optional |
|
|
expression |
optional |
|
|
application/ |
application/ |
|
|
URI |
optional |
|
| httpheaderlist |
ECMAScript expression |
optional |
|
get | post |
get |
|
|
variable names |
optional |
blocking
Whether to keep control until the sending operation is complete. If true, the send operation will have completed by the time control is returned to the VoiceXML application. If false, the send operation happens in the background, the application is not blocked, and processing continues to the next element.
dest
The dest attribute specifies the URI where data is sent.
Note: You can specify either the dest or the destexpr attribute, but not both.
destexpr
The destexpr attribute specifies an ECMAScript expression that evaluates to the URI where data is sent.
Note: You can specify either the destexpr or the dest attribute, but not both.
enctype
The enctype attribute specifies the encoding to use when posting data. The values you can set for this attribute are:
- application/x-www-form-urlencoded (default)—Data is submitted as specified in the HTML 4.01 Specification. Since this encoding can triple the size of data being submitted and is inefficient in performing encoding on binary data, it is not recommended for binary data such as recordings. Nuance recommends using the multipart/form-data encoding instead.
- multi-part/form-data—Data is submitted as a multipart MIME document (as defined in RFC 2388). Note that each key has its own part, including separate headers. Nuance recommends using this encoding when submitting binary data such as recordings.
- application/octet-stream—Data is submitted as a direct stream of values. Note that keys are not submitted. You can use this encoding to submit a single recording to a file URL, which effectively saves the recording to the specified file. Note that it is not possible to separate values on the remote side when submitting multiple items. As a result, Nuance does not recommend using this type when submitting multiple items.
fetchaudio
The fetchaudio attribute specifies the URI of the audio file to play while sending data.
httpheaderlist
The httpheaderlist attribute enables sending custom values in HTTP headers. It specifies an ECMAScript expression that evaluates to an array of headername, headervalue pairs.
Use this mechanism to customize HTTP requests submitted to servers by the Voice Browser service on behalf of VoiceXML applications. It sends runtime information so servers can understand the context of requests and format appropriate responses. Your VoiceXML application (or the voice application server itself) can insert custom values for any purpose. This example assigns httpheaderlist to someHeaders:
var someHeaders = [
{headername: "Content-Type", headervalue: "text/html; charset=UTF-8"}, {headername: "custom-hrd1", headervalue: "custom-value1"}];
One use of custom headers is to identify the current state of the call and enable the VoiceXML application to initiate a relevant action. Another use is to integrate a web server that provides data to the VoiceXML application: for example, to pass information to a server that validates credit cards.
Note: Use this attribute cautiously, and test thoroughly. Do not specify confidential data in the headers unless protected via TLS. In addition, your tests should ensure the server can respond to the custom values. It's best to create new, custom header/value pairs and avoid setting any standard pairs (because the values you specify will override tested defaults).
You must specify headers as an array of header/value pairs. This example creates two custom headers and values and uses httpheaderlist to insert them into a request:
<script><![CDATA[
function GetHeaders() {var myHeaders = [
{headername: "CustomHdr1", headervalue: "Hdr1Value"}, {headername: "CustomHdr2", headervalue: "Hdr2Value1 , Hdr2Value2"}, {headername: "Content-Type", headervalue: "text/html; charset=UTF-8"},];
return myHeaders; }
]]></script>
.....
<form id="get_quote">
<block>
<nuance:send name="quote" srcexpr="'http://myserver/account.html"
httpheaderlist="GetHeaders()" />
<assign name="document.quote" expr="quote.documentElement"/>
......
</block>
</form>
......
method
The method attribute specifies the HTTP method to use when sending data.
namelist
The namelist attribute specifies the list of variables to send to the server.
Children
None.
Parents
Sample code
<!-- The <nuance:send> element behaves much like the <submit> element, with one key difference. The application does *not* transition to the URL location, it simply HTTP POSTs data to the location. In this particular case, the data posting is for the purpose of logging.-->
<nuance:send dest="http://www.profiler.com/user_counter.jsp" method="post" enctype="application/x-www-form-urlencoded" namelist="time_spent userid"/>