Hi,
The <data> tag always requires an xml response. If you're hosting your vxml files from a regular web server, you can interact with your api through any programming language supported by the server. For example, you could dynamically generate your vxml files through php, in which case you would have all the capabilities of the high level language as well as serving up the vxml files. This is the general approach for interacting with web services, but otherwise the <data> tag is the only real native vxml way to interact with remote services, which is limited to xml returned from the service.
For utilizing web services from a web server that is hosting your vxml scripts, the process generally follows the pattern of: gather your input from the caller; submit that to another script (either via <submit> or <sudbialog>, via GET or POST, such that the high level language can access the values; call your api through your high level language, and then move on with your call. Here's a basic example that uses the <submit> tag to submit POST data to another script, which calls a function (let's pretend the function is actually defined somewhere and implements a web service) and then processes the result and branches on the result of the response:
start.vxml
Code: Select all
<?xml version="1.0"?>
<vxml version="2.0">
<form id="enter_account_number">
<field name="account_number" type="digits?length=2">
<prompt>
Please enter your 2 digit account number.
</prompt>
<filled>
<submit next="account.php" namelist="account_number" method="post"/>
</filled>
</field>
</form>
</vxml>
account.php
Code: Select all
<?php
header('Content-type: text/xml');
// pretend there's an include here for the script with the get_account_info() method
// get the account number submitted via POST
if (isset($_POST['account_number'])) {
$account_data = get_account_info($_POST['account_number']);
if ($account_data != FALSE) {
$first_name = $account_data['first_name'];
$last_name = $account_data['last_name'];
}
}
echo("<?xml version=\"1.0\"?>\n");
?>
<vxml version="2.0">
<?php if (isset($first_name, $last_name)) { ?>
<form id="valid_account">
<block>
<prompt>
Hello, <?= $first_name ?> <?= $last_name ?>.
</prompt>
<exit/>
</block>
</form>
<?php } else { ?>
<form id="invalid_account">
<block>
<prompt>
Sorry, your account was not found.
</prompt>
<exit/>
</block>
</form>
<? } ?>
</vxml>
Alternatively, you could use the <data> tag to submit your data to a wrapper function that would take the submitted params, make the request to your api, gather the json response from your api, then format the response to xml and return it, in which case you could parse it directly from the <data> tag, however this approach also requires an intermediary web server.
Hopefully that helps, but please let us know if you have any additional questions.
Regards,
Plum Support