Samples Tutorial

     Previous  Next    Open TOC in new window    View as PDF - New Window  Get Adobe Reader - New Window
Content starts here

Updating Web Services Using Update Override

You can also use update overrides to update a Web service.

 


Objectives

After completing this lesson, you will be able to:

 


Overview

Unlike relational data sources, Web service updates are not automated, because ALDSP is unable to determine how to decompose a read function into a corresponding write. To enable ALDSP to perform the necessary writes, you must create an update override for the physical data service, and then implement the necessary writes in that update override. For example:

public class CreditRatingExit implements UpdateOverride { 
    public boolean performChange(DataGraph datagraph){   
        
    // don't do anything if there are no changes
        ChangeSummary cs = datagraph.getChangeSummary();
        if (cs.getChangedDataObjects().size()==0)
            return true;
    
    // get changed values from SDO
       GetCreditRatingResponseDocument creditRating = (GetCreditRatingResponseDocument) datagraph.getRootObject();
       int newRating = creditRating.getGetCreditRatingResponse().getGetCreditRatingResult().getRating();
       String customerId = creditRating.getGetCreditRatingResponse().getGetCreditRatingResult().getCustomerId();
       
    // update CreditRating web service       
       try {
            CreditRatingDBTestSoap ratingWS = new CreditRatingDBTest_Impl().getCreditRatingDBTestSoap();
            CreditRating rating = new CreditRating(newRating,customerId);
            ratingWS.setCreditRating(rating);
       } catch (Exception e) {
            e.printStackTrace();
            return false;
       }
       System.out.println("WEB SERVICE EXIT COMPLETE!");
       return true;
    }
} 

 


24.1 Creating an Update Override for a Physical Data Service

The clientgen utility in WebLogic generates a Web Service-specific client .jar file that client applications can use to invoke Web Services. You simply need to specify the WSDL URI, the name and location of the client.jar file to generate and a package structure. Clientgen is available as an ant task as well as a Java application that can be invoked from the command line.

For more information on clientgen see:

http://download.oracle.com/docs/cd/E13222_01/wls/docs81/webserv/anttasks.html

Objectives

In this exercise, you will:

Instructions

Set the clientgen command line utility to generate a Web service client .jar file by completing the following steps:

  1. Edit the setenv.cmd, located in <beahome>\weblogic81\samples\LiquidData\EvalGuide, to point to your WebLogic Server installation. This will set the environment for running clientgen. For example:
  2. call <beahome>\weblogic81\server\bin\setWLSEnv.cmd
    set CLASSPATH=d:\bea\weblogic81\server\lib\webservices.jar;%CLASSPATH%
    echo %CLASSPATH%
  3. Open the command prompt.
  4. Navigate to the <beahome>\weblogic81\samples\LiquidData\EvalGuide folder.
  5. Run setenv.cmd.
  6. Run clientgen.cmd to generate CreditRatingWSClient.jar.
  7. In WebLogic Workshop add CreditRatingWSClient.jar to your application's Libraries folder. The .jar file should be located in <beahome>\weblogic81\samples\LiquidData\EvalGuide.

 


24.2 Writing Web Service Update Logic in the Update Override

You now should set the update override class to the CreditRatingExit. This will let you get any updated credit rating information, invoke the CreditRating Web service, and pass in the new value.

Objectives

In this exercise, you will:

Instructions

  1. Right-click the WebServices folder, located in the DataServices folder.
  2. Choose Import.
  3. Navigate to <beahome>\weblogic81\samples\LiquidData\EvalGuide and select CreditRatingExit.java.
  4. Click Import.
  5. Build the DataServices project.
  6. Open getCreditRatingResponse.ds in Design View. The file is located in the WebServices folder.
  7. In the Property Editor, set the update override class by selecting CreditRatingExit from DataServices\WebServices.
  8. Build the DataServices project.

 


24.3 Testing the Update Override

You are now ready to test whether the update override functions correctly.

Objectives

In this exercise, you will:

Instructions

  1. Open CreditRatingDBTest.jws, located in the CreditRatingWS folder.
  2. Click the Start icon. The Workshop Test Browser opens.
  3. Enter CUSTOMER3 in the customer_id field and click getCreditRating(x1).
  4. Click the Test XML tab.
  5. Copy the SOAP body for the getCreditRating() function.
  6. <getCreditRating xmlns="http://www.openuri.org/">
      <!--Optional:-->
      <customer_id>string</customer_id>
    </getCreditRating>
  7. Close the Workshop Test Browser.
  8. Open getCreditRatingResponse.ds in Test View.
  9. Paste the SOAP body into the Parameter field.
  10. Change <customer_id>string</customer_id> to <customer_id>CUSTOMER3</customer_id>.
  11. Click Execute.
  12. Click Edit and modify the credit rating. The update override is functioning correctly if you can update the credit rating.
  13. Figure 24-1 Test View of Update Override for a Web Service


    Test View of Update Override for a Web Service

 


24.4 Checking for Change Requirements

You can now use the Web service to perform update overrides.

Objectives

In this exercise you will:

Instructions

  1. Open CustomerPageFlowController.jpf, which is located in the CustomerManagementWebApp folder. The Workshop Test Browser opens.
  2. Click the Start icon.
  3. Enter CUSTOMER3 in the CUSTOMER ID field and click Submit.
  4. Click Update Profile, change the credit rating information, click Submit, and then click Submit All Changes.
  5. Confirm if the credit rating was updated, by clicking Back, entering CUSTOMER3 in the CUSTOMER ID field, and clicking Submit.
  6. Figure 24-2 Workshop Test Browser View of Update Override Functionality


    Workshop Test Browser View of Update Override Functionality

 


Lesson Summary

In this lesson, you learned how to:


  Back to Top       Previous  Next