DDWeb Services
DDWeb Services
Designer Applications
AS; Reviewed:
SPOC 6/3/2008
1 of 37
DDWeb_Services
Contents
About this Tutorial ............................................................................................................................ 3
Intended Audience .............................................................................................................. 3
Prerequisites ....................................................................................................................... 3
Chapter 1:
Introduction ............................................................................................................ 4
1.1
1.2
Chapter 2:
2.1
2.2
2.3
Summary.............................................................................................................. 22
Chapter 3:
3.1
3.2
3.3
Authentication ...................................................................................................... 26
3.4
Headers................................................................................................................ 26
Chapter 4:
4.1
4.2
References..................................................................................................................................... 36
AS; Reviewed:
SPOC 6/3/2008
2 of 37
DDWeb_Services
An Introduction describing the fundamental components of Web Services and Web Services
Description Language (WSDL).
The procedure for consuming Web Services using standard Java tools as well as Avaya
Dialog Designer.
An overview of the Web Services Operation (WSOP) File.
A method of tracing Web Service calls.
The tutorial presents an overview of Web Services and the elements contained in a Web Service
document. The steps involved in consuming a Web Service within an application using standard Java
tools are then described and this approach is then contrasted with the ease of consuming the same Web
Service using the built in Dialog Designer Web Services connector. The structure of a Dialog Designer
WSOP file and its features are discussed. The process of tracing Web Service calls is also described.
After completing this tutorial, the developer will be familiar with:
Intended Audience
This document is intended for developers developing Web Service applications using Avaya Dialog
Designer.
Prerequisites
A basic understanding of the Web Services model and familiarity with Java programming and telephony
application call flows are required. This tutorial is primarily intended for application developers and
managers familiar with the technical aspects of self service application design.
AS; Reviewed:
SPOC 6/3/2008
3 of 37
DDWeb_Services
Chapter 1: Introduction
A Web Service is a software system designed to support interoperable machine to machine interaction
over a network. Web Services are Web APIs that can be accessed over a network, such as the Internet,
and executed on a remote system hosting the requested services.
In common usage, the term Web Service refers to clients and servers that communicate using XML
messages that follow a standard, such as Simple Object Access Protocol (SOAP). A Web Service
provider is an application which provides functionality to be accessed over the network. A Web Service
consumer locates this functionality and invokes the operations provided by the Web Service.
A Web Service makes software application resources available over networks using standard
technologies. Being based on standard interfaces, Web Services provide an implementation-independent
way for applications to communicate with each other.
Figure 1:
Figure 1 above shows the relationship between a Web Service (in the center), its client software
applications (on the left), and the resources it uses, including databases, other Web Services, and so on
AS; Reviewed:
SPOC 6/3/2008
4 of 37
DDWeb_Services
(on the right). A Web Service communicates with clients and resources using standard protocols, such as
HTTP, by exchanging XML messages. The application server on which the Web Service is deployed is
responsible for routing incoming XML messages to the Web Service code. The Web Service exports a
WSDL file to describe its interface, which other developers may use to write components to access the
service.
AS; Reviewed:
SPOC 6/3/2008
5 of 37
DDWeb_Services
types: The WSDL types element is a container for XML Schema type definitions. The type
definitions placed here are referenced from higher-level message definitions in order to define the
structural details of the message. The following example code shows a typical implementation of the
types element:
<definitions name="GoogleSearch"
<types>
<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="urn:GoogleSearch">
<xsd:complexType name="GoogleSearchResult">
<xsd:all>
<xsd:element name="documentFiltering"
type= "xsd:boolean"/>
</xsd:all>
</xsd:complexType>
</types>
</definitions>
message: The WSDL message element defines an abstract message that can serve as the input or
output of an operation. Messages consist of one or more part elements, where each part is
associated with either an element (when using document style) or a type (when using RPC style).
The following example code shows a typical implementation of the message element:
<definitions name="GoogleSearch"
<message name="doGetCachedPage">
<part name="url" type="xsd:string"/>
</message>
</definitions>
portType: The WSDL portType element defines a group of operations, also known as an
interface in most environments. A portType element contains zero or more operation elements. The
following example code shows a typical implementation of the portType element:
<definitions name="GoogleSearch"
<portType name="GoogleSearchPort">
<operation name="doGetCachedPage">
<input message="typens:doGetCachedPage"/>
<output message="typens:doGetCachedPageResponse"/>
</operation>
</portType>
</definitions>
AS; Reviewed:
SPOC 6/3/2008
6 of 37
DDWeb_Services
binding: The WSDL binding element describes the concrete details of using a particular
portType with a given protocol. The binding element contains several extensibility elements as well
as a WSDL operation element for each operation in the portType it's describing. The following
example code shows a typical implementation of the binding element:
<definitions name="GoogleSearch"
<binding name="GoogleSearchBinding" type="typens:GoogleSearchPort">
<soap:binding style="rpc"
transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="doGetCachedPage">
<soap:operation soapAction="urn:GoogleSearchAction"/>
<input>
<soap:body use="encoded"
namespace="urn:GoogleSearch"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body use="encoded"
namespace="urn:GoogleSearch"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
</binding
</definitions>
service: The WSDL service element defines a collection of ports, or endpoints, that expose a
particular binding. The sample code below shows a typical implementation of the service element:
<definitions name="GoogleSearch"
<service name="GoogleSearchService">
<port name="GoogleSearchPort" binding="typens:GoogleSearchBinding">
<soap:address location="http://api.google.com/search/beta2"/>
</port>
</service>
</definitions>
Each port must be given a name and a binding assigned to it. Within the port element, an extensibility
element then has to be used to define the address details specific to the binding.
AS; Reviewed:
SPOC 6/3/2008
7 of 37
DDWeb_Services
AS; Reviewed:
SPOC 6/3/2008
8 of 37
DDWeb_Services
Step 2.
AS; Reviewed:
SPOC 6/3/2008
9 of 37
DDWeb_Services
2. Setting Classpath:
a. To set the Classpath from the command line:
For this tutorial, JDK 1.5.0 must be installed and the path to the bin directory must
be set as shown in the figure. The other .JAR files in the classpath can be located
under the <Axis installfolder>/web-inf/lib> directory. Refer the
screenshot below:
b. The following steps show an alternative procedure that may be followed to set the
Classpath. The screenshots show the parameters to be configured to set the
Classpath.
i. Locate and right click on the My Computer icon on the desktop and select
Properties from the dropdown menu, as shown below:
AS; Reviewed:
SPOC 6/3/2008
10 of 37
DDWeb_Services
ii. Click on the Advanced tab. Click Environment Variables on the Advanced
tab to set the Environment Variables parameters as shown below.
iii. Click the New button shown below to add a System Variable.
AS; Reviewed:
SPOC 6/3/2008
11 of 37
DDWeb_Services
iv. In the New System Variable edit box enter CLASSPATH in the Variable name
field and complete path to all the JAR files (in the
<Axis installfolder>/web-inf/lib> directory) under the
Variable value field as shown below
AS; Reviewed:
SPOC 6/3/2008
12 of 37
DDWeb_Services
Step 3.
Writing the Java client application in the servlet node in Dialog Designer.
The tutorial uses Eclipse based Dialog Designer environment to demonstrate the
interaction between a Java client application and Web Service. However, the steps
involved in invoking a Web Service from a Java client application built using other
environments/platforms are similar.
1. Open a new Dialog Designer speech project called webservices in Dialog Designer (an
Eclipse plug-in). Create a call flow as per the requirements of the desired application.
As shown in the screenshot below, in this application, two announce nodes (welcome
and result) along with the Java servlet node are used.
The first announce node plays a welcome greeting to the caller. The Java servlet node
(shown below) acts as the client to access the required Web Service and the result
fetched from the Web Service is announced in the result node. In the example call flow
shown below, insert a Java servlet node (currencyconvertor) as shown below.
AS; Reviewed:
SPOC 6/3/2008
13 of 37
DDWeb_Services
2. Right-click on the Java servlet node and select the Edit currencyconvertor.java
option from the drop-down menu as shown below.
AS; Reviewed:
SPOC 6/3/2008
14 of 37
DDWeb_Services
3. Edit the servlet file to add the client side code which consists of the required URL to
access the WSDL file.
Note: If the application is executed from within a firewall, proxy settings may be required
to be configured. To configure proxy settings, ensure that the following code snippet is
included in the client servlet:
System.getProperties().put("http.proxyHost", "10.111.14.14");
System.getProperties().put("http.proxyPort", "8080");
System.getProperties().put("http.proxyUser", "username");
System.getProperties().put("http.proxyPassword", "password");
AS; Reviewed:
SPOC 6/3/2008
15 of 37
DDWeb_Services
4. Run the Speech project from the Eclipse IDE to get the output result. This output result
can then be announced using an announce node as shown below. Refer to Avaya
Dialog Designer Getting Started with Dialog Designer 4.0 ([1]) for help on running the
application.
This application can also be deployed on Avaya Voice Portal and Avaya Interactive
Response. For deployment procedures, refer to tutorial Deployment of Speech and
Call Control Applications on Avaya Voice Portal and Avaya Interactive Response
available on the DevConnect portal
(https://devconnect.avaya.com/public/dyn/d_dyn.jsp?fn=446)
AS; Reviewed:
SPOC 6/3/2008
16 of 37
DDWeb_Services
Create a new Speech project. Right click on the project and select New. Choose Web
Service Operation File as shown below. If Web Service Operation File is not visible,
select Other and then select Web Service Operation File from the Avaya Speech
Development option.
AS; Reviewed:
SPOC 6/3/2008
17 of 37
DDWeb_Services
Step 2.
Enter an appropriate name in the File Name column and enter the Web Service URL in the
WSDL URL column as shown below. In the Authentication drop down, select No
Authentication. Click on the Load button; if the load is successful, a drop down list
containing the operation supported by the Web Service is displayed. Select
ConversionRate (currency, currency) operation. Click the Next button.
Step 3.
AS; Reviewed:
SPOC 6/3/2008
18 of 37
DDWeb_Services
Step 4.
The screen shown below is for mapping output parameters. Click Auto Create to
automatically create the variable ConverseRateResult and click Finish.
NOTE: Changes to creating and mapping of variables can also be done by editing the
WSOP file as shown in the screenshot below.
AS; Reviewed:
SPOC 6/3/2008
19 of 37
DDWeb_Services
Step 5.
Select the Application Flow view and drag the Data node from the Application Items
section in the palette as shown below. Rename the node.
Step 6.
Double click the Data node to open it. Drag the Web Service node from the palette and
select the WSOP file that was created earlier from the drop down list in the properties
window as shown below. Save the settings.
AS; Reviewed:
SPOC 6/3/2008
20 of 37
DDWeb_Services
Step 7.
Make the changes in the webservices.java file. Include the code that follows to access
the Java object variables by over-riding the requestBegin (mySession) method as
shown below.
NOTE: This is an optional step. The Web Service referenced in this tutorial needs input
variable types other than built-in data types. Hence, the application needs to map the DD
variables to the appropriate type required by the Web Service. This step is required only in
such cases. If the Web Service parameters are directly mapped to the input or output
variables, then this step is not required.
AS; Reviewed:
SPOC 6/3/2008
21 of 37
DDWeb_Services
2.3 Summary
Consuming Web Services using standard Java tools demands an in-depth understanding of Web
Services and generating stubs using the WSDL2Java tool. Developers need to take care of correctly
passing values to Web Services and retrieving data from the responses. They are also responsible for
setting the desired header values.
In contrast to this, Dialog Designer provides a GUI interface known as Web Services Operation File
(WSOP) wizard for accessing Web Services. This wizard creates stubs, generates the client code and
also maps the variables used by the speech applications to the appropriate input/output variables.
AS; Reviewed:
SPOC 6/3/2008
22 of 37
DDWeb_Services
AS; Reviewed:
SPOC 6/3/2008
23 of 37
DDWeb_Services
AS; Reviewed:
SPOC 6/3/2008
24 of 37
DDWeb_Services
AS; Reviewed:
SPOC 6/3/2008
25 of 37
DDWeb_Services
3.3 Authentication
Authentication selects how Dialog Designer should authenticate with the Web Service host. The
available options are:
a. No Authentication Username/password are not required for authentication.
b. Basic - Transmits the username/password pair in an unencrypted form from browser to server
in the HTTP header.
c. Digest - Transmits the username/password pair in an encrypted from the browser to server in
the HTTP header.
The username and password fields are displayed only when Basic or Digest authentication is selected.
Enter a username and optionally a password for authentication.
3.4 Headers
When the Web Service request is sent to the server, two types of headers can be included with the
request; headers included in the HTTP header section or SOAP headers. Both are configured in this
section. Each header must be given a unique name and the value for the header is taken from a Dialog
Designer variable.
The direction of the header can be set to IN, OUT or both IN and OUT. If the direction is set to IN, the
value of the header is taken from the Web Service response and stored in the selected DD variable. If the
direction is set to OUT, the value of the DD variable is added to a header sent with the Web Service
request. The screenshots for Headers are shown below.
AS; Reviewed:
SPOC 6/3/2008
26 of 37
DDWeb_Services
Clicking on Capture > Options on the main menu in Wireshark opens the Capture Options
window shown in Step 2. The Capture Options dialog lets the user specify various
parameters for capturing live packet data.
AS; Reviewed:
SPOC 6/3/2008
27 of 37
DDWeb_Services
Step 2.
The Capture Options window shown below contains the Interface field, which lets the user
specify the interface (source) from which to capture packet data or a command from which
to get the packet data via a pipe. Select the systems Ethernet (LAN) card from the
Interface drop-down list and click Start.
AS; Reviewed:
SPOC 6/3/2008
28 of 37
DDWeb_Services
Step 3.
After clicking Start, run the application related with the Web Service to check the logs in
Wireshark and then click Stop as shown below.
AS; Reviewed:
SPOC 6/3/2008
29 of 37
DDWeb_Services
Step 4.
Like other protocol analyzers, Wireshark's main window shows three views of a packet. It
shows a summary line, briefly describing what the packet is. A packets detailed display is
also shown, allowing the user to narrow down the exact the protocol or field that he or she is
interested in (shown below).
Step 5.
Check the SOAP request and response and ensure that the correct values are passed
during the SOAP requests and responses.
AS; Reviewed:
SPOC 6/3/2008
30 of 37
DDWeb_Services
Starting the TCPMon (TCPMonitor is also referred to as TCPMon) utility. There are two
ways to accomplish this:
a. Open a command prompt (either by clicking Start -> Run and typing
cmd.exe or via Start -> Programs -> Accessories -> Command Prompt)
and change the directory to the Tomcat Lib directory. Make sure that the
Axis.jar file is present under this directory. An example path to
<Tomcat Home>/Lib directory is shown in the screenshot below. To open
TCPMonitor, type:
java cp axis.jar org.apache.axis.utils.TCPMonitor
as shown below.
b. Browse to the TCPMON build folder and run the tcpmon.bat file. The
TCPMonitor screen with the default settings should be displayed as shown
below.
AS; Reviewed:
SPOC 6/3/2008
31 of 37
DDWeb_Services
Step 2.
Open a Dialog Designer based Web Service application as shown below. Select a WSOP
file in the Navigator view under wsoperations folder and open it in the editor as shown
below.
Step 3.
Replace a section of the Endpoint URL as shown below to enable debugging using
TCPMonitor. The example describes the same using Currency Convertor Web Service.
Displayed URL: http://www.webservicex.net/CurrencyConvertor.asmx
New URL: http://localhost:9999/CurrencyConvertor.asmx
Save the WSOP file when done.
Note:
a. Any valid port that is currently not in use by another application can be used instead of
9999. Port 8080 should not be used as it currently used by Apache Tomcat.
b. Since a Web Service port is not specified in the existing URL, the default HTTP port 80
is used by this Web Service.
AS; Reviewed:
SPOC 6/3/2008
32 of 37
DDWeb_Services
Step 4.
Change the TCPMonitor settings as shown below to reflect the changes made to the
Dialog Designer application.
Specify the Listen Port # as 9999.
Select the Listener radio button under the Act as a... option.
Specify the Target Hostname as www.webservicex.net
Specify the Target Port # as 80.
Click on the Add button to finalize the changes.
Note:
The Listen Port field value must match the value entered for the port on which the Web
Service end point is set.
The Target Hostname field value should be set to point to the Web Services server
(name/IP).
The Target Port value is the port number on which the Web Service operates.
AS; Reviewed:
SPOC 6/3/2008
33 of 37
DDWeb_Services
Step 5.
Verify that a tab indicating the listener port is displayed as shown below.
Step 6.
Click on the tab and verify the port numbers. A waiting for connection message
should also be displayed as shown below.
AS; Reviewed:
SPOC 6/3/2008
34 of 37
DDWeb_Services
Step 7.
View the Web Service details in the TCPMonitor display as shown below. Click on the
Save button to save the information displayed to a file. The top pane in the screenshot
shows Web Service SOAP header information and the bottom pane displays the SOAP
message body.
AS; Reviewed:
SPOC 6/3/2008
35 of 37
DDWeb_Services
References
[1]
[2]
[3]
AS; Reviewed:
SPOC 6/3/2008
36 of 37
DDWeb_Services
AS; Reviewed:
SPOC 6/3/2008
37 of 37
DDWeb_Services