SimpleTimer.jws Sample

A simple web service that demonstrates use of the Timer control. Uses the @jws:timer timeout= tag.

# Concepts Demonstrated by this Sample

- Use of a Timer control

- Declaration and use of a client callback

- Use of Conversations

# Location of Sample Files

This sample is located in the timer folder of the samples WebLogic Workshop project. In the file system the location is:

BEA_HOME\weblogic700\samples\workshop\applications\samples\timer\SimpleTimer.jws

# How to Run the Sample

To run this web service:

1. Start WebLogic Server in the appropriate domain.

   - On Microsoft Windows systems, from the Start menu navigate to:

   BEA WebLogic Platform 7.0->WebLogic Workshop->WebLogic Workshop Examples->Start Examples Server.

   - On Linux or Solaris systems, run:

   BEA_HOME/weblogic700/samples/workshop/startWebLogic.sh

2. Launch the service either by opening it in WebLogic Workshop and selecting the Start operation or by entering http://localhost:7001/samples/timer/SimpleTimer.jws in the address bar of your browser. If WebLogic Server is running in the appropriate domain on this machine, you may click here to run the sample.

3. Navigate to the Test Form tab of Test View, if necessary.

4. Invoke the createTimer method to create a new conversational instance.

5. Click on the conversation ID (the large number) in the Message Log to access this conversation's continue and finish methods.

6. Invoke the setAlarm method. This starts the Timer control, which will expire in 5 seconds.

7. When the timer expires, it calls its onTimeout callback, which arrives at SimpleTimer via the timer_onTimeout callback handler.

8. The timer_onTimeout callback handler in turn invokes SimpleTimer's onAlarm callback to the client.

9. You must refresh the browser to see callbacks arriving from the service. The use of a browser for Test View does not allow WebLogic Server to push notification to the browser when callbacks execute.

10. setAlarm uses the Timer control's restart method, so invoking setAlarm before the timer expires will reset it so that it will expire 5 seconds from the invocation of setAlarm.

11. Refresh the browser periodically until the callback.onAlarm callback entry appears in the Message Log.

12. Select log entries in the Message Log to see the message traffic involved in each interaction.

Related Topics

AdvancedTimer.jws Sample

Controls: Using Resources from a Web Service

Timer Control: Using Timers in Your Web Service

Maintaining State with Conversations

Using Callbacks to Notify Clients of Events

Test View