IBM Support

Record HTTP Traffic from Rational Integration Tester

Question & Answer


Question

How can you record HTTP traffic from IBM Rational Integration Tester (RIT)? What is an example of how it can done?

Answer

Using IBM Rational Test Workbench to record HTTP traffic

This paper will demonstrate how to use IBM Rational Integration Tester (RIT) and the HTTP Proxy Server which is part of the IBM Rational Integration Tester Platform Pack (RITPP) to record HTTP traffic. This solution is equally suitable for users of IBM Rational Test Virtualization Server (RTVS) and IBM Rational Performance Test Server (RPTS), since those products include the former components.

For the exercise we will use the “add numbers” example server which ships with IBM Rational Integration Tester (RIT) to make possible the exercises in the “Getting started with Rational Integration Tester, web services overview” section of the product documentation. That documentation deals with how to create a client for the “add numbers” service using IBM Rational Integration Tester. Here we will instead use a trivial Java program as the client so that it is clear that IBM Rational Integration Tester does not need to be used to invoke the web service. This client will be compiled for the Microsoft Windows operating system only.

Prerequisites

Before working through the steps in this document it is necessary to install IBM Rational Integration Tester (RIT), IBM Rational Test Control Panel (RTCP) and the IBM HTTP Proxy Server from the IBM Rational Integration Tester Platform Pack (RITPP) and configure the IBM HTTP Proxy Server to connect to the instance of IBM Rational Test Control Panel (RTCP).

The system under test

The Web Service Client will invoke the Web Service. In order to record this traffic we will force the Web Service Client to invoke the Web Service via the IBM HTTP Proxy which comes with the IBM Rational Integration Tester Platform Pack (RITPP). The IBM HTTP Proxy will then report its results to observers registered with the IBM Rational Test Control Panel (RTCP). Any instance of IBM Rational Integration Tester (RIT) which has opened a project which is registered with the instance of IBM Rational Test Control Panel (RTCP) will then be able to record that traffic.



The above diagram shows the logical layout of the components in the system. To follow this white paper as a training exercise all of these components may be run on the same computer.

Running the system under test server

In “C:\Program Files\IBM\RationalIntegrationTester\examples\addnumbers” there is a “start.bat” script which can be used to launch the service GUI. (On some computers it may also be started by simply double clicking the JAR file.) Once it is launched you may change the TCP/IP port number. Please ensure the port selected is not in use. Then click the “Start Service” button.



Building the system under test client

Because there is no sample client supplied with IBM Rational Integration Tester (RIT) we must create our own. We are going to do this in Java.

The example given is constructed using the IBM Java 7 JDK, and the %javahome% environment variable has been configured to reach the “ibm_sdk70” folder.

Here is a minimal Java client for the web service. This code is adequate for the exercise. It is not intended to be production quality code. It is not necessary to understand this code in order to follow the rest of the document. Create an empty folder and a text file named “AddNumbersClient.java”. The capitalization of the filename must match exactly. Cut and paste the Java code into the file.

import endpoint.gh.AddNumbersService;
import endpoint.gh.AddNumbers;

class AddNumbersClient {
private static void displayf(String msg, Object... args) {
String str = String.format(msg, args);
javax.swing.JOptionPane.showMessageDialog(null,str);
}

private static String[] demandArgs() {
String msg = "Input command line: <int> <int>";
String line = javax.swing.JOptionPane.showInputDialog(null,msg).trim();
return line.split("\\s+");
}

public static void main(String... args) {
Integer a = null, b = null, res = null;

try {
if (args.length == 0) args = demandArgs();
if (args.length != 2) throw new java.lang.IllegalArgumentException();
a = java.lang.Integer.parseInt(args[0]);
b = java.lang.Integer.parseInt(args[1]);
} catch (Exception e) {
displayf("Syntax: <int> <int>");
System.exit(1);
}

try {
AddNumbersService service = new AddNumbersService();
AddNumbers port = service.getAddNumbersPort(); // Web Service port (not TCP/IP port)
res = port.addition(a,b);
} catch (Exception e) {
displayf( e.getMessage() );
System.exit(1);
}

displayf("Web Service returns: %d + %d = %d%n", a, b, res);
}
}


In the same folder create a text file “compile.bat”. Copy and paste this text. If the service host or port number are different for your system change these in the URL on line ending “?wsdl”.

@ECHO OFF
setlocal
pushd .

if not exist ".\endpoint" %javahome%\bin\wsimport http://localhost:8088/addNumbers?wsdl

%javahome%\bin\javac -cp . AddNumbersClient.java

echo Manifest-Version: 1.0 > MANIFEST.MF
echo Main-Class: AddNumbersClient >> MANIFEST.MF
%javahome%\bin\jar cmf MANIFEST.MF AddNumbersClient.jar AddNumbersClient.class endpoint

popd
endlocal


From the command line execute the “compile” command to build the client. This will create the AddNumbersClient.jar output program in the current folder.

Running the system under test client

To run the client use the command line (from the folder containing the AddNumbersClient.jar file).


java -jar AddNumbersClient.jar

 

The client input window will appear.



Enter two integer values separated by a space and click OK. The result will be displayed.



To run the client and force the application to use the proxy server use the command line:

java -Dhttp.proxyHost=localhost -Dhttp.proxyPort=3128 -Dhttp.nonProxyHosts= -jar AddNumbersClient.jar


The output should look exactly as before.

N.B. These additional parameters are options passed to the JVM, rather than a feature coded into the client application, so these JVM parameters should work with all Java applications.

It is good practice to stop the proxy service at this point to show that the client will now error if the proxy server is not running, and the JVM arguments are included in the command line.



Remember to restart the proxy server after doing this.

The IBM Rational Integration Tester (RIT) Project.

Create a new project using IBM Rational Integration Tester. The project creation wizard will request connection details for the results database and for the instance of IBM Rational Test Control Panel, which should be supplied.

(The same details can be added to a project after creation. This is done from the “Project” menu, “Project Settings…” option and the “Server Settings” tab. In this case the “Publish results database connection” button must be clicked after the settings have been correctly entered.)

Create an environment within the project. The name given is unimportant.

Switch to Architecture School, Physical View. Create a “Web Server” from the “Web” menu. Specify the hostname and TCP/IP port of the Web Service (i.e. the Add Numbers service stated earlier in the document). Do not supply any details of the proxy server. On the recording tab ensure that the recording mode is set to “External Proxy Server”.





Now switch to Architecture School Logical View and create an “HTTP Connection” from the “Web” menu. Name it “addNumbersHost”. (Any name will do, but it will be easier to follow the document if this name is chosen.) Bind this to the physical web server for your environment.

Now switch to Recording Studio. Add an item to record (by clicking the green plus icon). A dialog appears. By default this dialog only shows operations, and so our resource is not shown. Click the “show recordable resources” icon (which looks a little like a Rubik’s cube) and select “addNumbersHost”. Click OK.



Click the “Start Recording” icon in the Events View panel. (The icon is a red circle. It is one of two red circle items currently on the display, so be sure to use the one in the Events View.)



A dialog will appear whilst recording is starting. Wait for this to complete. If any error is displayed resolve the problem and then repeat the operation before proceeding.

Run the client again. The recorded HTTP traffic will appear. Here we used the service to add the numbers 12 and 17 to get 29.



As you can see our application has sent two requests and received two replies.

The first request (line 1) is to retrieve the WSDL and the WSDL is then sent back on (line 2). Not all applications will do this, and the Add Numbers program does not require this to be done before the service is called.

The second request (line 3) is the request to add the two numbers.



The response is sent back on (line 4).



You may wish to pause recording at this stage, so no additional messages are recorded.

Generating a test from the recording

To generate a test from the recording we need a service component and operation defined.

Return to Architecture School Logical View and create a Service Component from the “General” menu. Give it a name (e.g. “sc”).

Now return to recording studio. Select lines 3 and 4 from the recording. Right click and select “Save Test”.



Work through the wizard, accepting the defaults, and providing our service component and letting the wizard create the operation for the recording.



Click “Next”.



Click “Next”.



Click “Next”.



Click “Select” and select the service component “sc” and then click “Next”.



Click “Next”.



Provide a name for the test (e.g. “Add12and17”) and click “Finish”.

Reviewing the Generated Test

You should now be able to run your test in Test Lab, or modify or copy it in Test Factory etc.



Note the operation created by saving the test in Architecture School Logical View:



And note how the generated operation has been bound to the service.





(The topic of stubs is beyond the scope of this document.)

Troubleshooting

It is worth reviewing some of the links between the components in this system, and how they can be checked and corrected if necessary.

The IBM Rational Integration Tester (RIT) project must connect to the instance of IBM Rational Test Control Panel (RTCP). This is defined within the Project Settings found on the Project menu within RIT. The green tick indicates that the value entered is valid.



The HTTP Proxy Server must also be registered with the instance of IBM Rational Test Control Panel. This software is part of IBM Rational Integration Tester Platform Pack and the initial value will have been set during installation. The value is in the HTTP Proxy registration.xml which by default on Microsoft Windows will be found at “C:\Program Files\IBM\RIT-Platform\httptcp\registration.xml”.

<?xml version="1.0" encoding="UTF-8"?><registration>
<!-- Connection details to the Rational Test Control Panel instance -->
<server base-url="http://127.0.0.1:7819/RTCP"/ >
  …  
 

The relevant value is found in the document at location “/registration/server/@base-url”. If this value is modified then the service “IBM RIT HTTP Proxy” must be restarted from Control Panel, Services.
With the RIT HTTP Proxy server correctly registered with IBM Rational Test Control Panel this will be visible from the Agents page of the control panel.



In the above screen shot the row of type “HTTP, HTTPS” shows that there is a RIT HTTP Proxy registered with this instance of IBM Rational Test Control Panel.

Troubleshooting routing rules

From Rational Test Control Panel the associated proxy routing rules may be seen by clicking the magnifying glass icon at the right hand end of the line. Only traffic matching a condition in one or more of these rules will be recorded.



For example the first routing rule is:

(URL Prefix: / AND port=7777) AND (host=IBM-E5NK0U3RM4G OR ((host=192.168.56.1 OR (host=192.168.0.2 OR host=9.146.150.103)) OR (((source host=9.146.150.103 OR source host=192.168.0.2) OR source host=192.168.56.1) AND (host=localhost OR (host=127.0.0.1 OR host=0:0:0:0:0:0:0:1)))))


Which can be reformatted as:

(URL Prefix: / AND port=7777) AND
( host=IBM-E5NK0U3RM4G
OR ((host=192.168.56.1 OR (host=192.168.0.2 OR host=9.146.150.103))
OR ( ((source host=9.146.150.103 OR source host=192.168.0.2) OR source host=192.168.56.1)
AND (host=localhost OR (host=127.0.0.1 OR host=0:0:0:0:0:0:0:1)))))


This shows that traffic to any endpoint on point 7777 of host IBM-E5NKOU3RM4G will be recorded (and also includes capturing expressions for traffic directed by IP Address and relevant traffic coming back from that machine where the host is one of the various forms of localhost). Once this is understood only the first three items (prefix, port and host) in the expression commonly need review.

[{"Product":{"code":"SSBLQQ","label":"IBM Rational Test Workbench"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Rational Integration Tester","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF016","label":"Linux"},{"code":"PF022","label":"OS X"},{"code":"PF027","label":"Solaris"},{"code":"PF033","label":"Windows"}],"Version":"8.0;8.5","Edition":"","Line of Business":{"code":"LOB45","label":"Automation"}}]

Document Information

Modified date:
11 July 2019

UID

swg21654498