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
-
Start WebLogic Server in the appropriate domain.
-
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.
-
Navigate to the Test Form tab of Test View, if necessary.
-
Invoke the start method to create the
database table and populate it with test data.
-
Click on the conversation ID (the large number in the Message Log) to
access the continue and finish methods for that conversation.
-
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.
-
Any winners found are returned in a string, as the return value of drawNumber.
-
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.
-
Select log entries in the Message Log to see the message traffic involved
in each interaction.
-
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.