IRS.jws Sample

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

Sample Location

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

BEA_HOME/weblogic81/samples/workshop/SamplesApp/WebServices/creditReport/

Sample Source Code


01 package creditReport; 
02 
03 /**
04  * IRS.jws is a very simple service for use by the CreditReport.jws sample
05  * service.  IRS simulates a "long-running" procedure by using a timer
06  * to delay its asynchronous response.
07  *
08  * Note that Bank.jws and IRS.jws are identical except for method names
09  * and the default duration of the timer timeout.
10  * @common:target-namespace namespace="http://workshop.bea.com/IRS"
11  */
12 
13 public class IRS implements com.bea.jws.WebService
14 
15   
16     /**
17    <p>A Timer Control is used to simulate an operation that takes some time.</p>
18    *
19      * @jc:timer timeout="10 seconds"
20      * @common:control
21      */
22     private com.bea.control.TimerControl timer;
23 
24     /*
25      * Store the customer ID number that is passed in so we can use it in the
26      * asynchronous response.
27      */
28     private String ssn;
29 
30     public Callback callback;
31 
32     public interface Callback
33     {
34         /*
35          * onDeliverTaxReport is a callback delivered to the client when
36          * processing is complete.
37          */
38         /**
39          * @jws:conversation phase="finish"
40          */
41         public void onDeliverTaxReport(String result);
42     }
43 
44     
45 
46     /**
47      <p>Starts the asynchronous tax report operation.  When it is complete
48      * the onDeliverTaxReport callback will be called.  If cancelReport is
49      * invoked before the results are delivered, results will never be delivered.</p>
50      *
51      * @common:operation
52      * @jws:conversation phase="start"
53      */
54     public void requestTaxReport(String ssn)
55     {
56         /* store the customer ID for later use */
57         this.ssn = ssn;
58         
59         /* 
60          * start the timer, which simulates starting the long-running procedure
61          */
62         timer.start();
63     }
64 
65     /*
66      * Handler for onTimeout events from the "timer" Timer Control.
67      * onTimeout simulates the long-running procedure reaching completion,
68      * so a result is sent to the client via the onDeliverAnalysis callback.
69      */
70     private void timer_onTimeout(long timeout)
71     {
72         /*
73          * Use a completely arbitrary scheme to decide who's approved and
74          * who's not.  Some people think real banks work this way.
75          */
76         if ((ssn.length() 4&& (ssn.charAt(3<= '5'))
77         {
78             callback.onDeliverTaxReport("Taxes Delinquent");
79         }
80         else
81         {
82             callback.onDeliverTaxReport("Taxes Current");
83         }
84     }
85 
86     /**
87      <p>Cancels the request.  The onDeliverTaxReport callback
88      * will not be called and the conversation is finished.</p>
89      
90      * @common:operation
91      * @jws:conversation phase="finish"
92      */
93     public void cancelReport()
94     {
95         timer.stop();
96     }
97 
98 
99