
IBM eNetwork Communications Server for Windows NT, Version 6.01 Host Publisher Feature
[Next|Previous|Contents]
Sample 2
This is the second sample that uses the Host Simulator.
The user specifies the
userid and password on a Web form; the integration object
invokes a host
application and collects data from it; and an error
macro detects and recovers from a disconnected state.
This sample is much more complicated than the previous
one. Please work through that one if you have not done so
already, and ensure it is working before attempting this one.
Somewhat less detailed instructions will be given for this sample
so it doesn't get too lengthy.
There are two host simulator files for this sample.
sample2a.smp shows normal operation, while
sample2b.smp is a host session in which the
previous session was not properly logged off, so the logon
appears in a reconnected state.
Follow these steps:
- Create a new WBL by selecting the menu item File/New/Library.
- Create a new book (File/New/Book).
- Create the Web page where the user will provide a userid
and password as follows:
- Select menu item File/New/Page
- Right-click on the new Web page, select Rename page, and
name it Page1.
- Enter the following text into the Web page:
<form action="page2.dml" method="get">
Enter a userid and password and press submit:<br>
Userid <input name="userid" size=8><br>
Password <input type=password name="password" size=8><br>
<input type=submit value="Submit">
<input type=reset value="Reset">
</form>
This enables the user to provide a userid and password and
pass them to the second Web page, which provides them to
the integration object.
- Create the integration object.
- Select menu item File/New/Integration Object.
- Set the type of the integration object to Host Access.
- Click Configuration and specify Host Server localhost
and port 2300.
- Ensure that you are on the Macro page in the Integrator
and that the Connect macro is selected.
- Click Attach and select the macro file
sample1_logon.hmf to use the same connect macro
as the first sample.
- Modify the connect macro to use the user-provided
userid and password as follows:
- Click Edit.
-
In the macro editing window, find the line
ps.SendKeys("langw[tab]ab1c2d[enter]");
This macro command sends the userid and password to the host.
-
Before the ps.SendKeys line, insert these two lines:
prompt(20,16,8,":userid","",true);
prompt(21,16,8,":password","",true,"*");
These lines enter the userid and password provided by the
user at screen positions 20,16 and 21,16. These are row,column
positions. The previous line "screenDesc.AddCursorPos(20,16)"
told us the cursor was at 20,16 when the host was prompting
for the userid, and we know that the password field is
one row lower. We could also have identified these screen positions
from the terminal window. The row and column cursor position is
shown in the terminal window's lower right corner.
-
Remove "langw[tab]ab1c2d" from the ps.SendKeys line,
leaving only
ps.SendKeys("[enter]");
-
Press the window close button in the upper-right corner of
the macro editing window to close the window.
-
Save the modified macro using the name "sample2_logon.hmf".
-
Click Attach and attach the macro file
"sample2_logon.hmf" as the connect macro.
- Select the Disconnect macro.
- Click Attach and select the macro file
sample1_logoff.hmf. This will use the same disconnect macro
as the first sample.
- Click Show/Hide Terminal to show the terminal window.
Move and resize it so you can still work with the Integration Object while
the terminal window is visible.
- Start the Host Simulator and specify port 2300 and the input
file sample2a.smp.
- Click Connect. You should see the MSG10 screen.
- Select the Connect macro and click Play.
You should see the logon sequence.
- Select the Data loop macro and click Record.
We will start the filelist application and then exit
it. Note that the simulator session paged through the
file list rather than
exiting immediately, so things will look odd on the screen while we do
this. We'll arrange to page through the file list later.
- In the terminal window, press Esc to send
a Clear, then
type filelist and hit
Enter, then hit F3 to exit.
- Click Stop recording. Close the macro edit
window, and save the macro as sample2_loop.hmf.
- Now define a screen to recognize
the filelist application window.
- Return to just
after logon by hitting Disconnect, stopping and restarting
the Host Simulator, then hitting Connect and playing
the Connect macro.
- Press Escape (Clear),
type filelist and hit Enter to reach the filelist screen.
- In the Integrator, change to the Screens panel.
Click Add... and define a new screen called "results".
In the terminal window, use the mouse to
mark the line of text across the column
headings as the confirmation text, e.g. the
row that begins with "Cmd Filename". This is a good way
to identify the filelist application screen.
- Now define some data items.
Change to the Items panel. Click Add... and enter the
name filename. Now use the mouse to mark the
entire Filename column in the terminal window.
Repeat for filetype, date, and time.
- Since not all of the output of the filelist application
is visible initially, define a screen macro to
page through the output until the end.
- Use the Screens tab to return to the results
screen definition
- Use the Macro tab on the smaller window to change from
the Properties window to the screen Macro window.
- Click the Record button.
- In the terminal window, press F8 to page down.
- Click Stop Recording and save the macro as
sample2_screen.hmf.
- In the Iterations section, change the setting
to Until text visible, then mark the blank line
that should be visible near the bottom of the filelist screen,
near row 19, where there was file information on the
first screen. This identifies the end of the
file list.
- Change the Limit # of iterations to 30, just
to be safe; you might use a higher number if you expect
many files in your filelist.
This completes the configuration of the integration
object.
- Select the Web book in the upper left window.
- Select the menu item File/Page Wizard.
- Title the new page page2. (Recall that your
first Web page was set up to send its form input to "page2.dml".)
Click Next.
- Select Table Data Layout and click Next.
- Select Use an existing integration object and click Next.
- Select the integration object you just created and click Next.
- Select, in order, the items filename, filetype,
date, and time. Click Next.
- Click Finish.
You are now ready to try it.
- Restart the Host Simulator.
- Select page1
- Click the Preview
tab,
- Fill in a userid and
password.
- Click Submit.
Error handling
We left out one feature, handling the case where the account
gets disconnected without properly logging off. To see how this
looks, set the Host Simulator to use input file sample2b.smp,
connect, and logon. Instead of the usual Ready; prompt after
logging in, you see RECONNECTED AT and the time. At
this point, we can't be sure what state the account is in, and
it is safest to just IPL before continuing.
We will recognize this state from our data loop macro
by defining a screen with the RECONNECTED string as
confirmation text, and then associating an error with that
screen, also using the RECONNECTED string as confirmation text.
The macro associated with the error will trigger the IPL.
(We could instead have used a screen macro associated with
the screen itself, with an iteration count of 1.)
In order to recognize this screen, we need to start our data loop
macro with a WaitForScreen that will succeed regardless of whether
we're reconnected (since if it fails, Host Publisher will stop
processing the integration object). The easiest way to do this is to
identify text that appears in either case, shortly before the RECONNECTED or
Ready; prompt. In our example, we look for the string
FILES:.
- Select the data loop macro and click Edit.
- The first three lines should contain
screenDesc.Clear();
screenDesc.AddCursorPos(23,1);
ps.WaitForScreen(screenDesc,10000);
Change the second line to
screenDesc.AddString("FILES:");
so your macro starts with
screenDesc.Clear();
screenDesc.AddString("FILES:");
ps.WaitForScreen(screenDesc,10000);
- Close the macro edit window and save the macro.
- Start the Host Simulator with sample2b.smp
- Connect and play the Connect macro. You should see
the RECONNECTED string below the FILES: line.
- Go to the Screens window, define a screen called
reconnected, and select the RECONNECTED string
as the confirmation text.
- Define the error.
- Go to the Errors window and Add... an error.
- Give it an ID of 0 and long and short names of reconnected
(these don't really matter).
- Select RECONNECTED as the confirmation text.
- Change to the Type panel.
- Set the severity to Recoverable
- Hit Record under the Macro section.
- In the terminal window, type IPL and hit Enter.
- Click Stop recording.
- Before saving the macro, add the following lines to the end
so that the macro will wait until the IPL is complete:
screenDesc.Clear();
screenDesc.AddString("Ready;");
ps.WaitForScreen(screenDesc,10000);
- Now save the macro as sample2_error.hmf.
You can try it just as before,
except use sample2b.smp in the Host Simulator. Switch back
and forth between sample2a.smp and sample2b.smp and verify that
it works either way.
Note: This error handler does not function correctly
if the integration object is scoped to client. The integration
object does not logon, and the string "FILES:" does not appear
when the data loop macro is executed the second time.
[Next|Previous|Contents]
IBM eNetwork Communications Server for Windows NT, Version 6.01 Host Publisher Feature