QuoteService.jws Sample

This topic inludes the source code for the QuoteService.jws Sample.

Sample Location

This sample is located in the following directory in your WebLogic Workshop installation:

BEA_HOME/weblogic81/samples/workshop/SamplesApp/WebServices/service/

Sample Source Code


01 package service; 
02 
03 import java.lang.Math;
04 import com.bea.control.TimerControl;
05 
06 /**
07  <p>This is the original service from which QuoteServiceControl.jcx was
08  * generated. Notice that the getQuote method takes two parameters.  In
09  * QuoteService.jcx, the signature of the method is changed to accept a
10  * single parameter and hard-code the other.</p>
11  
12  <p>See the comments in QuoteServiceControl.jcx for details.</p>
13  
14  * @common:target-namespace namespace="http://workshop.bea.com/QuoteService"
15  */
16 public class QuoteService implements com.bea.jws.WebService
17 
18     String symbol;
19 
20     /**
21      * @common:control
22      * @jws:timer timeout="5 seconds"
23      */
24     private TimerControl timer;
25 
26     public Callback callback;
27 
28     public interface Callback
29     {
30         /**
31          * @jws:conversation phase="finish"
32          */
33         public void onQuoteReady(String tickerSymbol, double dQuote);
34     }
35 
36     /**
37      * This method is called by the QuoteClient.jws web service
38      * via the QuoteServiceControl control. Note that although the 
39      * client isn't passing a customer ID value, this service receives
40      * one because the value is hardcoded in an XQuery map on the 
41      * service control. The customer ID is not used, but is printed 
42      * to the WebLogic Server console window.
43      
44      * @common:operation
45      * @jws:conversation phase="start"
46      */
47     public void getQuote(int customerID, String tickerSymbol)
48     {
49         System.out.println("customer ID: " + customerID);
50         
51         symbol = tickerSymbol;
52         timer.start();
53     }
54 
55     private void timer_onTimeout(long time)
56     {
57         callback.onQuoteReadysymbol, (double)(Math.random() 30.0) );
58     }
59