ControlTest.jws Sample

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

Sample Location

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

BEA_HOME/weblogic81/samples/workshop/SamplesApp/WebServices/controlProjectTest/

Sample Source Code


001 package controlProjectTest; 
002 
003 /**
004  * A web service to test the controls built from the JavaControlProject
005  * project in the SamplesApp application. <br/><br/>
006  
007  * If you change code in those controls to try other scenarios, 
008  * remember to build JavaControlProject (right-click JavaControlProject, 
009  * then click Build JavaControlProject). When you build that project, the 
010  * resulting JavaControlProject.jar file is copied to the Libraries of 
011  * the SamplesApp application. From there, they are accessible to
012  * this web service. <br/><br/>
013  
014  * Note that the WebServices project also includes local versions 
015  * of these controls, along with a corresponding test web service.
016  * @common:target-namespace namespace="http://workshop.bea.com/ControlTest"
017  */
018 public class ControlTest implements com.bea.jws.WebService
019 
020     public Callback callback;
021 
022     /**
023      * @common:control
024      */
025     private verifyFunds.VerifyFunds verifyFundsControl;
026 
027     /**
028      * Tests the VerifyFunds control, which submits purchase
029      * order information after ensuring that inventory and
030      * the customer's account support it. <br/><br/>
031      
032      * To test the control, enter a PO number, customer ID,
033      * item number, and item quantity. After clicking testVerifyFunds,
034      * click Refresh until Test View displays the results of the
035      * test as a message returned by the verifyFundsTestDone callback.
036      
037      * The following table lists item numbers and quantities known 
038      * to the database when WebLogic Workshop is installed. The 
039      * VerifyFunds control decreases quantities with successful 
040      * orders. This web service gives the customer a balance 
041      * of $200.00 to spend for each request. You can change 
042      * this amount to test with another.
043      
044      <table style="font-size: 8 pt">
045      <tr><td style="width: 100px">itemNumber</td><td style="width: 100px">quantity</td><td>price</td></tr>
046      
047      <tr><td>624</td><td>5</td><td>34.95</td></tr>
048      <tr><td>625</td><td>6</td><td>39.95</td></tr>
049      <tr><td>629</td><td>10</td><td>34.95</td></tr>
050      <tr><td>631</td><td>15</td><td>65.95</td></tr>
051      <tr><td>640</td><td>1</td><td>24.95</td></tr>
052      
053      </table>
054      
055      @param  poNumber  A number for this purchase order. May be any
056      * number, and may include non-numeric characters (these will be removed
057      * by the control).
058      @param  customerID  The customer's unique ID. This may be any number.
059      @param  item  The number for the item being ordered. Use a number from
060      * the range given above.
061      @param  quantity  The number of the specified items to order. Note that
062      * this number must be lower than the quantities given above in order
063      * for this order to succeed. Give larger numbers to test the control's
064      * inventory checking. Also, keep in mind that a successful PO transaction
065      * will decrease the inventory quantity in the database by the amount
066      * ordered.
067      * @common:operation
068      * @jws:conversation phase="start"
069      * @common:message-buffer enable="true"
070      */
071     public void testVerifyFunds(String poNumber, 
072         String customerID, int item, int quantity)
073     {
074         /*
075          * The amount the customer can spend. Changing this amount may
076          * change the results of the control's check to verify customer
077          * funds for the purchase.
078          */
079         double balance = 200.00;
080 
081         /* Call the VerifyFunds control with the details of the purchase order. */
082         verifyFundsControl.submitPO(poNumber, customerID, item, quantity, balance);
083     }
084 
085     /* 
086      * A handler for the VerifyFunds control's onTransactionComplete callback.
087      * The results are essentially summarized for a callback of this web service.
088      */
089     public void verifyFundsControl_onTransactionComplete(java.lang.String message, 
090         boolean balanceAvailable, boolean inventoryAvailable)
091     {
092         callback.verifyFundsTestDone(message + 
093             "\n Balance available: " + balanceAvailable +
094             "\n Inventory available: " + inventoryAvailable);
095     }
096 
097 
098     public interface Callback
099     {
100         /**
101          * Sends a response to the client of this web service when the VerifyFunds
102          * control's callback is received.
103          
104          * @jws:conversation phase="finish"
105          */
106         void verifyFundsTestDone(String responseMessage);
107     }
108 
109