The user may use his phone to call to the voice gateway. The voice gateway will interact as a voice browser, saying the output of the VoiceXML application and waiting for user inputs. It’ll use the internet to access the VoiceXML application, that is deployed in a Glassfish V2 UR2 application server for dynamic content generation. The database used to store user information and hotel reservation is a MySQl 5.1 Community edition.
The Glassfish server receives the voice gateway http requests, query the MySQL database and returns a web page with the requested information in VoiceXML syntax. Normally it’ll be a form with some input fields that must be filed by the user. The voice gateway then asks for user input and, once it’s finished, the information is sent back to the Glassfish server as a HTTP GET or POST.
Another option for the user is to access it right from the web. In my hotel reservation example, only the query for hotel reservations is allowed.
In the Glassfish side, I used the Java Server Pages technology with the Spring framework and iBATIS as the Data Mapper framework. From Spring, we used SpringMVC for the MVC design pattern, SpringORM for Spring Dao pattern and the dependency injection pattern.
This allowed me to easily create the application with all the functionality I needed. Note that the MVC pattern was applied in the voice application and the acronym still valid. Instead of View we have Voice. For the database modeling, MySQL Workbench was used, a great free tool for this task.
The database ended looking up like this:
another MySQL Workbench screenshot, showing the VoiceHotel Database Model
Once the database is created, you just need to generate the SQL script from MySQL Workbench and execute it with MySQL. The CLI command to do this is:
mysql -u user -p < script_file.sql
where user is the database user and -p will ask you for the password.
Other options is use your IDE for doing this or MySQL Workbench. The main Java IDEs are NetBeans and Eclipse. Both IDEs allows the connection with MySQL and the automatic deployment in Glassfish. Using Eclipse the deployment can be done coding a deploy task in one Ant build file, or using another mechanism like Maven. This makes the application development even faster.
With MySQL Workbench we have a set of nice and useful features like Import Reverse Engineer MySQL create script for importing a database from script, allowing us to edit this new database, and save these modifications. The databases can be exported using a feature called Forward Engineer SQL CREATE/ALTER script. Another nice thing is the visual insert editor, making a lot easier pre-populate the database with data.
With the Java and the VoiceXML code ready, we need to put it online. With Glassfish, all you need to do is either, use your IDE to deploy it with one click, or put the .war file in the autodeploy folder.
Another possibility is to make use of Glassfish Admin Console. With one Glassfish “fresh installation” this can be done accessing
http://localhost:4848/. Default administrator username is
admin and default password for admin user is
After logging in, all you need to do is access Web Applications section, click on deploy button, select your war file and that’s it.
VoiceXML applications are a great way to give more than one access possibility to a service and using Glassfish and MySQL for developing this kind of application is incredibly easy. You barely take notice of them :)
You can access the voice hotel application by calling +990009369996079911 from Skype and visualize the data by accessing http://inf.unisc.br/tmuller/viewDatabaseTableData.voice.
The project is located at http://voicehotel.dev.java.net and you can download all it’s source codes. More info is located at https://voicehotel.dev.java.net/source/browse/voicehotel/trunk/artifacts/documentation/.