You can also use update overrides to update a Web service.
After completing this lesson, you will be able to:
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;
}
}
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
Set the clientgen command line utility to generate a Web service client .jar file by completing the following steps:
call <beahome>\weblogic81\server\bin\setWLSEnv.cmd
set CLASSPATH=d:\bea\weblogic81\server\lib\webservices.jar;%CLASSPATH%
echo %CLASSPATH%
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.
You are now ready to test whether the update override functions correctly.
<getCreditRating xmlns="http://www.openuri.org/">
<!--Optional:-->
<customer_id>string</customer_id>
</getCreditRating>
You can now use the Web service to perform update overrides.
In this lesson, you learned how to: