YOUR FEEDBACK
Chris Keene's Prescription for Curing the Java Flu
Rob wrote: I have to agree with Chris - I have been a developer and Java a...
SOA World Conference
Virtualization Conference
$200 Savings Expire May 16, 2008... – Register Today!


2007 West
GOLD SPONSORS:
Active Endpoints
Your SOA Needs BPEL for Orchestration
BEA
Virtualized SOA: Adaptive Infrastructure for Demanding Applications
Nexaweb
Overcoming Bandwidth Challenges with Nexaweb
TIBCO
What is Service Virtualization?
SILVER SPONSORS:
WSO2
Using Web Services Technologies and FOSS Solutions
Click For 2007 East
Event Webcasts

2008 East
PLATINUM SPONSORS:
Appcelerator
Think Fast: Accelerate AJAX Development with Appcelerator
GOLD SPONSORS:
DreamFace Interactive
The Ultimate Framework for Creating Personalized Web 2.0 Mashups
ICEsoft
AJAX and Social Computing for the Enterprise
Kaazing
Enterprise Comet: Real–Time, Real–Time, or Real–Time Web 2.0?
Nexaweb
Now Playing: Desktop Apps in the Browser!
Sun
jMaki as an AJAX Mashup Framework
POWER PANELS:
The Business Value
of RIAs
What Lies Beyond AJAX?
KEYNOTES:
Douglas Crockford
Can We Fix the Web?
Anthony Franco
2008: The Year of the RIA
Click For 2007 Event Webcasts
SYS-CON.TV
TODAY'S TOP SOA & WEBSERVICES LINKS


Developing VoiceXML Applications Using Microsoft.NET

Digg This!

In Part 1 of this article (XML-J, Vol. 2, issue 6) we introduced the key components of the Microsoft .NET Framework - ASP.NET, C#, and Web Services. In Part 2 we apply the .NET technologies to develop an interactive VoiceXML application. Toward the end of the article we review the concept of Web Services and how it applies to the world of developing interactive voice applications.

Table 1 provides a summary of some of the key components of the .NET Framework that we utilize to develop an interactive VoiceXML application.

.NET and VoiceXML
We use the following Employee Directory scenario as our sample application, which is similar to the one we worked on in the February issue of XML-J (Vol. 2, issue 2). We also enhance the user interface to be more natural language-oriented using the grammar we developed in the May issue (Vol. 2, issue 5).

Application Scenario
First the user dials a number using a regular or cell phone. The system greets the user with a prompt, then waits for input; the user communicates with the system in almost natural language, "Please call Hitesh Seth on his mobile phone." After recognizing two important keywords from the user's input (name and phone type), the application uses Text-to-Speech (TTS) to present a system-generated voice message about the user, then transfers the call to the appropriate phone number.

The following conversation depicts the interaction between the user and the VoiceXML-based application.

  • User dials 1 (800) nnn-nnnn
  • System: Welcome to SeraNova Employee Directory. What can I do for you?
  • User: Please call Hitesh Seth on his mobile phone.
  • System: Calling Hitesh Seth on his mobile phone (732) 433-5603
  • System dials (732) 433-5603 and connects it to the user.
Application Design -
.NET in Our Application

Now we'll use essential components of the .NET Framework to model our VoiceXML-based application:
  • .NET components: They represent the object-relational database access model of the table "Employee". These components will be compiled into a dynamic link library (DLL) that's referenced by the ASP.NET Pages IIS Web Server and served through the IIS Web Server. (Typically, the DLLs are kept in the bin directory under the application root directory under IIS.) As we'll see later, .NET provides a platform for creating distributed Web Services that allow further partitioning of Web applications.
  • Set of ASP.NET pages: Collectively present a VoiceXML interface to a VoiceXML gateway.
Figure 1 shows the .NET Framework-based design of the employee directory application.

On the database side we have a relational database table Employee (Primary key - ID, other fields - name, e-mail, direct, cellular).

Employee Class
The Employee class represents an object model of the database table "Employee". Listing 1 shows the complete implementation of the Employee class using C#. Essentially, the class has one-to-one mapping of the fields in the Employee table as properties. This class is used by the employee business object to represent the employee entity.

Employee Business Object
A key component of our application is the employee business object. This object provides two methods - GetEmployee, which retrieves a particular employee's information, and GetEmployees, which returns a collection of employee objects. Listing 2 shows the implementation of the employee business object in C#. Alternatively, the employee business object can also be implemented in a different .NET-supported language such as Visual Basic.NET. Listing 3 shows a simple build script that can be used to compile the .NET component using the .NET C# language compiler (csc.exe).

Dynamic Web Scripting
Using ASP.NET

Now we use ASP.NET-based technology to query the object and present a VoiceXML user interface to the VoiceXML gateway. It's possible to have just one single ASP.NET page that generates the complete VoiceXML user interface. However, since an actual employee directory may consist of hundreds to thousands of employees, we split the script into three different pages - EmployeeDirectory.aspx (see Listing 4), Grammar.aspx (see Listing 5), and Employee.aspx (see Listing 6) - as shown in Figure 2.

The EmployeeDirectory.aspx page serves as the entry point to the VoiceXML gateway, with the grammar for the input represented by the page Grammar.aspx. When requested by the main application, the Employee.aspx page performs a lookup on a particular employee (based on ID) and forwards to the appropriate telephone number (mobile or direct).

The Grammar.aspx invokes the GetEmployees method of the employee business object and then iterates through the collection to create a grammar that matches all the employees in the possible utterances.

After the utterance is recognized by the speech recognition engine, the VoiceXML interpreter invokes the Employee.aspx page that decodes the input parameter cmd (encoded as <id>, <phone-type> e.g. 1,mobile), looks up the appropriate employee object, and presents the related employee information in a VoiceXML block (see Listing 6).

Web Services
Perceived by some as the fourth wave of computing, Web Services take the Web application model to the next level. Instead of the Web being applied to the traditional HTML-based information exchange, Web Services set the Web up to be a dynamic service bureau publishing a directory of collaborative IP-based services. Technically speaking, a Web service is essentially an XML request/ response-based interaction model for creating distributed applications. Web Services utilizes established Web protocols such as HTTP/HTTPS and facilitates the creation of loosely coupled and distributed IP-based services.

Web Services can also be used to create a loosely coupled distributed computing environment for the division of work/logic/computing power instead of (or along with) the traditional Remote Procedure Call-based, distributed objectbased distribution mechanism. For instance, the application tier can be conceived as a collection of Web Services connected with the presentation tier using HTTP/SOAP.

Let's see how Web Services apply here. We can remodel the employee business object of our application as a simple Web service called employee service. This service has two methods, GetEmployee and GetEmployees, that return data sets containing a particular employee by ID and all the directories of all the employees, respectively. Listing 7 shows the complete employee service.

An invocation of the Web service's methods, followed by a transformation with appropriate XSLT-based stylesheets, can then drive the delivery of our VoiceXML-based application (represented in Figure 3). Listing 8 provides a sample XML returned by invocation of the GetEmployees method on the EmployeeService (by invoking the URL http://localhost/EmployeeService.asmx/GetEmployees).

XML/XSLT transformation can be achieved by calling XslTransform directly:

<%@ Page language="C#" ContentType="text/xml" %>
<%@ Import Namespace="System.Xml" %>
<%@ Import Namespace="System.Xml.Xsl" %>
<%
Response.Write(Server.MachineName);
XslTransform xslt = new XslTransform();
xslt.Load(Server.MapPath
("EmployeeDirectory.xsl"));
XmlDocument xml = new XmlDocument();
xml.Load("http://localhost/EmployeeService.asmx/GetEmployees");
xslt.Transform(new Document
Navigator(xml),null,Response.Output);
%>

or by using the <asp:xml> server-side control as:

<%@ Page language="C#" ContentType=
"text/xml" %>
<%@ Import Namespace="System.Xml" %>
<%@ Import Namespace="System.Xml.Xsl" %>
<%
XmlDocument xml = new XmlDocument();
xml.Load("http://localhost/Employee
Service.asmx/GetEmployees");
xslt.Document = xml;
%>
<asp:xml id="xslt" TransformSource=
"EmployeeDirectory.xsl" runat=server/>

Conclusion
The .NET Framework provides developers with a lot of flexibility by allowing them to use a wide variety of programming languages. Even a simple scenario such as this brings out the advantages of the loosely coupled Web Services application model.

References

  1. Microsoft .NET Home Page: www.microsoft.com/net
  2. SOAP 1.1: www.w3.org/TR/SOAP/
  3. XSLT Specification: www.w3.org/TR/xslt
About Hitesh Seth
Hitesh Seth is chief technology officer of ikigo, Inc., a provider of XML-based web-services monitoring and management software. A freelance writer and well-known speaker, he regularly writes for technology publications on VoiceXML, Web Services, J2EE and Microsoft .NET, Wireless Computing & Enterprise/B2B Integration. He is the conference chair for VoiceXML Planet Conference & Expo.

XML JOURNAL LATEST STORIES . . .
EDI to XML: A Practical Approach
While EDI transactions account for most worldwide commercial activity, XML-based alternatives are beginning to gain traction. According to Forrester Research, stateful XML, stateless XML, and even flat file exchanges are all projected to grow at a faster rate than EDI over the next few
3rd International Virtualization Conference & Expo: Themes & Topics
From Application Virtualization to Xen, a round-up of the virtualization themes & topics being discussed in NYC June 23-24, 2008 by the world-class speaker faculty at the 3rd International Virtualization Conference & Expo being held by SYS-CON Events in The Roosevelt Hotel, in midtown
Red Hat Named "Platinum Sponsor" of Virtualization Conference & Expo
Red Hat is a trusted open source provider. Red Hat offers enterprise customers a long-term plan for building infrastructures on the quality and innovation of open source. Combining open source operating system platform, Red Hat Enterprise Linux, together with applications, management
JustSystems Contributes Key XBRL Rendering Technology to Financial Community
JustSystems announced that it is contributing intellectual property rights for its invention of eXtensible Business Reporting Language (XBRL) rendering technologies to XBRL International, the standards body responsible for the oversight of the XBRL specification. The invention, known a
JustSystems Launches Campaign for XBRL Success
JustSystems announced its campaign to help organizations adopt XBRL (eXtensible Business Reporting Language), the XML-based standard for communicating financial and business information. In related news, JustSystems also announced that it has contributed intellectual property rights of
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS
SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
Click to Add our RSS Feeds to the Service of Your Choice:
Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
Publish Your Article! Please send it to editorial(at)sys-con.com!

Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021

SYS-CON FEATURED WHITEPAPERS


ADS BY GOOGLE
BREAKING XML NEWS
SAP Accelerates the Path to SOA for Customers
has led to customer requests for training and education involving SAP's proven design and de