LuckyNumberDBClient.jws Sample

A sample that uses a database to store players and their lucky numbers. LuckyNumberDBClient uses the LuckyNumber.jws web service to generate random numbers in the range [1,20] inclusive, then checks for winners in a database and returns the number drawn and the list of winners, if any. The database is managed using the LuckyNumberDBControl.jcx Database control. LuckyNumberDBControl.jcx creates and manages a PLAYERS table in the database and implements queries against it. Demonstrates using SQL's CREATE, INSERT, SELECT and DROP statements in a database control.

Concepts Demonstrated by this Sample

Location of Sample Files

This sample is located in the database folder of the WebServices project in the SamplesApp sample application. In the file system the location is:

BEA_HOME\weblogic81\samples\workshop\SamplesApp\WebServices\database\LuckyNumberDBClient.jws

To Run the Sample

  1. Start WebLogic Server in the appropriate domain.
  2. Launch the service either by opening it in WebLogic Workshop and selecting the Start operation or by entering http://localhost:7001/WebServices/database/LuckyNumberDBClient.jws in the address bar of your browser. If WebLogic Server is running in the appropriate domain on this machine and you have deployed the SamplesApp sample application, you may click here to run the sample.
  3. Navigate to the Test Form tab of Test View, if necessary.
  4. Invoke the start method to create the database table and populate it with test data.
  5. Click on the conversation ID (the large number in the Message Log) to access the continue and finish methods for that conversation.
  6. Invoke the drawNumber method. The web service invokes the getLuckyNumber method of the LuckyNumber web service to obtain a random number. LuckyNumberDBClient then queries the database, via the LuckyNumberDBControl Database control, to see if there are any players holding that number.
  7. Any winners found are returned in a string, as the return value of drawNumber.
  8. Test View always show the details of a Message Log entry when it arrives. Since the invocation of getLuckyNumber occurred after the invocation of drawNumber, Test View is now displaying the details of the getLuckyNumber invocation. Select the drawNumber entry in the Message Log to see its formatted return string.
  9. Select log entries in the Message Log to see the message traffic involved in each interaction.
  10. Examine the source code for LuckyNumberDBClient.jws and LuckyNumberDBControl.jcx to see how the JCX file defines database operations and method shape and the web service uses the methods and data structures provided by the Database control.

Related Topics

CustomerDBClient.jws Sample

Using WebLogic Built-In Controls

Database Control

@jc:sql Tag

Test View