![]() |
|
![]() ![]() ![]() |
Creating Call Control Applications with Dialog Designer > Building Call Control Applications > Using Database and Web Service Operations | |
![]() |
Using Database and Web Service Operations |
Database operations and Web Service operations in a call control project are used in a very similar way to how they are used in speech applications. Also, they are defined in the same manner using the same wizards.
Database operations are used to connect and interact with SQL databases. Information can be collected from a caller and then written to the database. Information can also be retrieved from the database to be presented to the caller. See Working with Database Operations.
Web services are Internet-based queries and applications that can be used to perform a wide variety of functions. In Dialog Designer, Web services are invoked with a Web service operation file.
An example Web service can be to enable callers to get stock quotes or weather forecasts for their areas. Or, a Web service to enable callers to find out about the availability of airline flights or hotel reservations. Almost any Web service where information can be presented using audio files or Text-to-Speech can be used in a Dialog Designer application. See Working with Web Services.
At runtime, Dialog Designer will use Dbproxy and Wsproxy proxy classes to invoke Database operations and Web Service operations from within your CCXML content, respectively. Code to invoke Database operations or Web Service operations can be written by hand, or with call control projects. It is recommended to use the available Database operations and/or Web Service operations snippets on the Snippets tab within the CCXML Editor to automatically invoke these proxy classes for you.
The following transition invokes a DBOP by using the DbProxy in a fetch command. An input variable called `id' is created, assigned and then passed in on the namelist as well as the `classname' of the Database operation to invoke.
<transition event="connection.connected" state="init">
<log expr="'-- ' + event$.name +' -- [' + state +']'"/>
<log expr="' eventdata... \n' + objectToString(event$)"/>
<assign name="state" expr="'invokeDB'"/>
<var name="classname" expr="'connectivity.db.operations.getSayings'"/>
<var name="id" expr="getRandomNumber(10)"/>
<fetch next="'http://localhost:8080/InvokeDatabase/DbProxy'" type="'text/
ecmascript'" namelist="id classname"/>
</transition>
After the fetch completes, run the Database operation as follows:
Create a variable to obtain the output of the Database operation and results of the invocation. The <script> command invokes the script, runs the Database operation, and sets the output variables as well as the dbResult. In this example, we then use a "Saying" from the database to prepare a prompt to the caller.
<transition event="fetch.done" state="invokeDB">
<log expr="'--In Event FETCH.DONE--'"/>
<var name="Saying" expr="''"/>
<var name="dbResult" expr="'OKAY'"/>
<script fetchid="event$.fetchid"/>
<if cond="dbResult == 'OKAY'" >
<assign name="state" expr="'response'"/>
<log expr="'Saying is:' + Saying"/>
<dialogprepare type="'application/voicexml+xml'" connectionid =
"in_connectionid" src="'http://localhost:8080/InvokeDatabase/vxml/Saying.vxml'"
namelist="Saying" />
<else/>
<log expr="'--Error in DB call:' + dbResult"/>
<exit expr="'DB error'"/>
</if>
</transition>
For an array, you have to pass in the index:
<log expr="'Saying is : ' + Saying"/>
<log expr="'Saying is : ' + Saying[0]"/>
namelist="Saying" />
namelist="Saying[0]" />
![]() ![]() ![]() |
©2009, Avaya Inc. All rights reserved.
|