Sunday, November 20, 2011

Migrating the WEBDAV Business Rule Repository from Oracle SOA Suite 10g to Oracle SOA Suite 11g format and exposing the rules as a webservice.


Migrating the WEBDAV Business Rule Repository from Oracle SOA Suite 10g to Oracle SOA Suite 11g format and exposing the rules as a webservice.

If we had used the Business Rule in 10g the same should be migrated to 11g.The below are the steps to migrate the sample webdav rule repository from 10g to 11g and to expose the rule dictionary as a service.
  1. Create a folder Rules with child folders “jaxboutput” and “xsd”.
  1. Copy the xsd files used in 10g to build the Input/output of rule to xsd folder.
  1. Crete a java file “RuleMigrator.java” with the below contents.
import java.io.PrintWriter;
import java.util.ArrayList;
import oracle.rules.tools.migrator.MigrateRuleRepository;
public class RuleMigrator {
public RuleMigrator() {
super();
}
public static void migrateRule() throws Exception{
String parent_output_dir=System.getenv("rule.output.path");
MigrateRuleRepository conv = new MigrateRuleRepository();
// Set the output buffer
conv.setOutLog(new PrintWriter(System.out));
// Set input properties (SDK format)
conv.setOriginLocation(System.getenv("rule.repository.location"));
conv.setXSDOutputDir(parent_output_dir+"\\jaxboutput");
conv.setOriginType(MigrateRuleRepository.WEBDAV_REPO);
conv.setOriginUserid(System.getenv("rule.repository.username"));
conv.setOriginPassword(System.getenv("rule.repository.password"));
conv.setOriginDictionaryName(MigrateRuleRepository.MIGRATE_ALL);
conv.setOriginVersionName(MigrateRuleRepository.MIGRATE_ALL);
conv.setLogWithStackTrace(true);
conv.setXSDLocation(parent_output_dir+"\\xsd");
// Set output properties
conv.setDestinationLocation(current_dir+"\\Rules");
System.out.println("Before calling migrate");
conv.migrate();
String results = conv.getTotalStats();
System.out.print(results);
}
public static void main(String[] args) {
try
{
migrateRule();
}catch(Exception e) {
e.printStackTrace();
}
}
}

  1. Execute the MigrateRules.bat file
Change the environment values accordingly, change the <> to where the jr_dav.jar is available.

MigrateRules.bat

set MIDDLEWARE_HOME=C:\Oracle\Middleware
set JAVA_HOME=%MIDDLEWARE_HOME%\jdk160_21
set JDEV_HOME=%MIDDLEWARE_HOME%\jdeveloper
set rule.repository.location=http://<<10gserverhost>>:7777/<>
#e.g. http://<<10gserverhost>>:7777/OrderManagement
set rule.repository.username=<10g user name>
set rule.repository.password=
set rule.output.path=<< Path to Rules folder created>>
set CLASSPATH=%CLASSPATH%;%JAVA_HOME%\lib\tools.jar;utilities;%JDEV_HOME%/soa/modules/oracle.rules.migration_11.1.1/migrator.jar;%JDEV_HOME%/soa/modules/oracle.rules.migration_11.1.1/webdavrc.jar;%JDEV_HOME%/soa/modules/oracle.rules.migration_11.1.1/rulesdk.jar;<Jar_Path>\jr_dav.jar;%JDEV_HOME%/soa/modules/oracle.rules_11.1.1/rl.jar;%JDEV_HOME%/soa/modules/oracle.rules_11.1.1/rulesdk2.jar;%MIDDLEWARE_HOME%/oracle_common/modules/oracle.xdk_11.1.0/xmlparserv2.jar;%MIDDLEWARE_HOME%/oracle_common/modules/oracle.xdk_11.1.0/xml.jar;%MIDDLEWARE_HOME%/wlserver_10.3/server/lib/ojdbc6.jar;%JDEV_HOME%/webservices/lib/jaxrpc-api-10.1.3.jar;%JDEV_HOME%/webservices/lib/wsclient-10.1.3.jar;%MIDDLEWARE_HOME%/modules/com.oracle.ws.http_client_1.3.0.0.jar;%MIDDLEWARE_HOME%/oracle_common/modules/oracle.adf.model_11.1.1/adfm.jar;
%JAVA_HOME%\bin\javac RuleMigrator.java
%JAVA_HOME%\bin\java RuleMigrator
pause;

This will create all the migrated rule dictionaries to the “rule.output.path”


Create the Rule composite process and expose the dictionary as webservice:

  1. Create a generic application with the name e. g. “EAIRules”

  1. Create a SOA Project e.g. “OrderStatusRule” under the Rules application with “Composite with Business Rule Template” (delete the Project “Project1” created by default)


  1. Copy the Migrated Rule Dictionary e.g. OrderLineStatusDictionary141008.rules from the Rules output directory to the project folder (The project created in the previous step).

  1. From the JDeveloper popup window select “Import Dictionary” and click on “Import” button and select the “OrderLineStatusDictionary141008.rules” from the explorer.

  1. Click the option “Yes” on the next window then Click “OK”

  1. Create the Input/output variables based on the schema element (as per the 10g setting) as shown in the below diagrams.


  1. Select “Expose as Composite Service” option in the bottom of the screen. The dictionary itself, can be exposed as a Composite Service by checking the option as shown below, which means, you don’t need a BPEL (decide activity )to invoke the rules and the client can directly pass the payload to the decision service/dictionary and get the output.
  1. Click “OK”
  2. Delete the rule dictionary e.g. “OrderLineStatusDictionary141008.rules” copied to OrderStatusRule project in the previous step.
  3. Delete the “RuleSet1” from OrderLineStatusDictionary141008.rules created in JDeveloper.

  1. Suppose we had an alias for the filed e.g. permBillFlag is the alias for filed3 then the alias details are not migrated to 11g, the below steps should be executed to create the alias manually.
1. Select “Facts” and double click on “OrderLineStausFactsType”



2. Change the Alias name “field3” to “permBillFlag” as shown below diagrams then click “OK”.

  1. Select the “Decision functions” and double click on the “OrderLineStatusDictionary141008_DecisionService_1” function
  2. Remove “RuleSet1” from the selected list and add “OrderLineStausRuleSet” to the selected list, also make sure the options “Will Be invoked As A Webservice”,”Stateless” are selected.



  1. Verify the Input/output type once and click “Ok” and save the project.
  2. Deploy the Rule project to the server, the rule project can be invoked by any webservice client.

DOWNLOAD RuleMigration.zip


No comments:

Post a Comment