Monday, November 14, 2011

ANT Script Deployment for SOA composites


1. Overview:

Running ANT script requires
  • build.properties
  • build.xml
  • configplan.xml
for each environment

    1. build.properties
Below is the main build.properties file where the application home, sar location, config plan location, environment details are defined

Initially set up the Oracle soa home, Java home, Middleware home and set the JAR’s location
Mention the credentials like username, password, serverURL, port for each environment.
Also mention the below parameters for each environment
  • sarLocation – Location where the deployable JAR’s are placed
  • configplan – Location where the config plan is placed for that particular environment
  • forceDefault=true
Note:
i) In build.properties, the credentials of different environment can be added and the same can be referred in deployment.plan.environment.
ii) Update the Middleware home, java home, soa home, sar location, config plan location as per the environment
iii) Update the SAR location and Config plan location as per the system
1.2 build.xml
Build.xml is the main ANT script which can do all deployments and calls the internal ANT scripts.
With this script, multiple composites can be deployed or redeployed to the environment using a single ANT command
The target “deployComposites” uses the in built ant script “ant-sca-deploy.xml” which is located in the oracle sos home for deploying the composites. It inherits set of properties like serverURL, username, password, sarLocation, configplan from build.properties
Also logging is enabled int the ant script which will help in debugging
Below is the build.xml
<?xml version="1.0" encoding="iso-8859-1"?>
<project name="soaDeployAll" default="deployAll">
<echo>basedir ${basedir}</echo>
<echo>current folder ${basedir}</echo>
<property environment="env"/>
<property file="${basedir}/build.properties"/>
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="${all.needed.jars.path}/ant-contrib.jar"/>
</classpath>
</taskdef>
<target name="init">
<tstamp>
<format property="timestamp" pattern="yyyy-MM-dd_HH-mm-ss"/>
</tstamp>
<property name="build.log.dir" location="${basedir}/buildlogs"/>
<mkdir dir="${build.log.dir}"/> <property name="build.log.filename" value="build_${timestamp}.log"/>
<record name="${build.log.dir}/${build.log.filename}" loglevel="verbose" append="false"/>
<echo message="Build logged to ${build.log.filename}"/>
</target>
<target name="deployAll" depends="init">
<echo>Deploy for environment ${deployment.plan.environment}</echo>
<antcall target="deployAllComposites"/>
</target>

<!-- Following Actions are performed for Composite files in Managed Server - Deploy,Redeploy -->

<target name="deployAllComposites" depends="init">
<foreach target="deployComposites" param="Files">
<fileset dir="${sarLocation}" casesensitive="no" includes="*.jar"/>
</foreach>
</target>

<target name="deployComposites" depends="init">
<propertycopy name="deploy.serverURL" from="${deployment.plan.environment}.serverURL"/>
<propertycopy name="deploy.sarLocation" from="${deployment.plan.environment}.sarLocation"/>
<propertycopy name="deploy.user" from="${deployment.plan.environment}.user"/>
<propertycopy name="deploy.password" from="${deployment.plan.environment}.password"/>
<propertycopy name="deploy.forceDefault" from="${deployment.plan.environment}.forceDefault"/>
<basename file="${Files}" property="basename"/>
<echo>Deploy Project ${basename} for environment ${deployment.plan.environment}</echo>
<if>
<equals arg1="${deployAction}" arg2="deploy" />
<then>
<echo message="Deploying composites in ${deployment.plan.environment} server........." />
<ant antfile="${oracle.soa.home}/bin/ant-sca-deploy.xml" inheritAll="true" target="deploy">
<property name="serverURL" value="${deploy.serverURL}"/>
<property name="user" value="${deploy.user}"/>
<property name="password" value="${deploy.password}"/>
<property name="overwrite" value="true"/>
<property name="forceDefault" value="${deploy.forceDefault}"/>
<property name="sarLocation" value="${deploy.sarLocation}"/>
</ant>
</then>
</if>
</target>
</project>

1.3 configplan.xml
Generate the config plan for the soa composite . With this config plan, soa composites can be deployed environment independentSteps to genrate config plan:
i) select the composite.xml and generate config plan as below



ii) Config plan will be generated in jdeveloper and you can search and replace the environment dependent properties like file read location, JNDI, etc..
Below is the configplan.xml for the DEV environment.
<?xml version="1.0" encoding="UTF-8"?>
<SOAConfigPlan xmlns:jca="http://platform.integration.oracle/blocks/adapter/fw/metadata" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:orawsp="http://schemas.oracle.com/ws/2006/01/policy" xmlns:edl="http://schemas.oracle.com/events/edl" xmlns="http://schemas.oracle.com/soa/configplan">
<composite name="SISIntegration">
<!--Add search and replace rules for the import section of a composite
Example:
<searchReplace>
<search>http://my-dev-server</search>
<replace>http://my-test-server</replace>
<searchReplace>
<searchReplace>
<search>8888</search>
<replace>8889</replace>
<searchReplace>-->
<import>
<searchReplace>
<search/>
<replace/>
</searchReplace>
</import>
<!--Add search and replace rules for the service properties-->
<service name="ReadSummaryReport">
<property name="ValidationSummary">
<replace></replace>
</property>
<binding type="jca"/>
</service>
<service name="ReadErrorReport">
<property name="DetailedErrorReport">
<replace></replace>
</property>
<binding type="jca"/>
</service>
<service name="ReadBatchIdFromQueue">
<binding type="jca"/>
</service>
<service name="ReadSISOutputFile">
<property name="APInvoiceDir">
<replace></replace>
</property>
<binding type="jca"/>
</service>
<service name="ReadSummaryFile">
<binding type="jca"/>
</service>
<service name="ReadZip">
<binding type="jca"/>
</service>
<service name="ReadSISOutputFiles">
<property name="SISOutputLocation">
<replace>/home/ordmsr12/IATASISIntegration/SISOutputFiles/InputDir/</replace>
</property>
<binding type="jca"/>
</service>
<service name="ReadAPInvoice">
<property name="APInvoiceDir">
<replace>/u50/app/SOA11G/IATA/SISOutputFiles/IsXmlOutputDir</replace>
</property>
<binding type="jca"/>
</service>
<!--Add search and replace rules for the component properties
For components and service/reference bindings, you can add policy references.
Example:
<component name="*">
<wsp:PolicyReference orawsp:category="management" orawsp:status="enabled" URI="oracle/log_policy"/>
</component>-->
<component name="MiscInvoiceOutboundProcess">
<property name="activationAgent.PollDBNewRecords.className">
<replace>oracle.tip.adapter.fw.agent.jca.JCAActivationAgent</replace>
</property>
<property name="activationAgent.PollDBNewRecords.portType">
<replace>PollDBNewRecords_ptt</replace>
</property>
<property name="bpel.preference.TargetHostName">
<replace>rstn-lin38.us.oracle.com</replace>
</property>
<property name="bpel.preference.TargetUserName">
<replace>ordmsr12</replace>
</property>
<property name="bpel.preference.TargetPassword">
<replace>ordmsr121234</replace>
</property>
<property name="bpel.preference.TargetSISDir">
<replace>/home/ordmsr12/IATA/SISIntegration/MiscOutboundFiles/</replace>
</property>
<property name="bpel.preference.InvoiceXMLPath">
<replace>/u50/app/SOA11G/IATA/MiscOutboundFiles/</replace>
</property>
<property name="bpel.preference.IndexFilePath">
<replace>/u50/app/SOA11G/IATA/MiscOutboundFiles/</replace>
</property>
</component>
<component name="AcknowledgementProcess">
<property name="activationAgent.ReadSummaryReport.className">
<replace>oracle.tip.adapter.fw.agent.jca.JCAActivationAgent</replace>
</property>
<property name="activationAgent.ReadSummaryReport.portType">
<replace>Read_ptt</replace>
</property>
<property name="bpel.preference.ValidationSummarySourcePath">
<replace>/u50/app/SOA11G/IATA/SISOutputFiles/ValidationRepDir/</replace>
</property>
</component>
<component name="ErrorReportProcess">
<property name="activationAgent.ReadErrorReport.className">
<replace>oracle.tip.adapter.fw.agent.jca.JCAActivationAgent</replace>
</property>
<property name="activationAgent.ReadErrorReport.portType">
<replace>Read_ptt</replace>
</property>
<property name="bpel.preference.ErrorReportSourcePath">
<replace>/u50/app/SOA11G/IATA/SISOutputFiles/ValidationRepDir</replace>
</property>
</component>
<component name="MiscInvoiceReadingZipProcess">
<property name="bpel.preference.InputDir">
<replace>/u50/app/SOA11G/IATA/SISOutputFiles/InputDir</replace>
</property>
<property name="bpel.preference.SupportingDocsDir">
<replace>/u50/app/SOA11G/IATA/SISOutputFiles/SupportingDocsDir</replace>
</property>
<property name="bpel.preference.ValidationRepDir">
<replace>/u50/app/SOA11G/IATA/SISOutputFiles/ValidationRepDir</replace>
</property>
<property name="bpel.preference.OfflineArchDir">
<replace>/u50/app/SOA11G/IATA/SISOutputFiles/OfflineArchDir</replace>
</property>
<property name="bpel.preference.IsXmlOutputDir">
<replace>/u50/app/SOA11G/IATA/SISOutputFiles/IsXmlOutputDir</replace>
</property>
</component>
<reference name="InvoiceInternalFileWrite">
<binding type="jca"/>
</reference>
<reference name="FetchLineRecords">
<property name="jca.retry.count">
<replace>4</replace>
</property>
<property name="jca.retry.interval">
<replace>1</replace>
</property>
<property name="jca.retry.backoff">
<replace>2</replace>
</property>
<property name="jca.retry.maxInterval">
<replace>120</replace>
</property>
<binding type="jca"/>
</reference>
<reference name="FetchHeaderAttachment">
<property name="jca.retry.count">
<replace>2147483647</replace>
</property>
<property name="jca.retry.interval">
<replace>1</replace>
</property>
<property name="jca.retry.backoff">
<replace>2</replace>
</property>
<property name="jca.retry.maxInterval">
<replace>120</replace>
</property>
<binding type="jca"/>
</reference>
<reference name="FetchLineAttachment">
<property name="jca.retry.count">
<replace>2147483647</replace>
</property>
<property name="jca.retry.interval">
<replace>1</replace>
</property>
<property name="jca.retry.backoff">
<replace>2</replace>
</property>
<property name="jca.retry.maxInterval">
<replace>120</replace>
</property>
<binding type="jca"/>
</reference>
<reference name="IndexInternalFileWrite">
<property name="IndexFileDir">
<replace>/u50/app/SOA11G/IATA/MiscOutboundFiles/</replace>
</property>
<binding type="jca"/>
</reference>
<reference name="ReadDetailErrorReport">
<binding type="jca"/>
</reference>
<reference name="UpdateHeaderTable">
<property name="jca.retry.count">
<replace>4</replace>
</property>
<property name="jca.retry.interval">
<replace>1</replace>
</property>
<property name="jca.retry.backoff">
<replace>2</replace>
</property>
<property name="jca.retry.maxInterval">
<replace>120</replace>
</property>
<binding type="jca"/>
</reference>
<reference name="InsertErrorTable">
<property name="jca.retry.count">
<replace>4</replace>
</property>
<property name="jca.retry.interval">
<replace>1</replace>
</property>
<property name="jca.retry.backoff">
<replace>2</replace>
</property>
<property name="jca.retry.maxInterval">
<replace>120</replace>
</property>
<binding type="jca"/>
</reference>
<reference name="FetchLineAndTax">
<property name="jca.retry.count">
<replace>4</replace>
</property>
<property name="jca.retry.interval">
<replace>1</replace>
</property>
<property name="jca.retry.backoff">
<replace>2</replace>
</property>
<property name="jca.retry.maxInterval">
<replace>120</replace>
</property>
<binding type="jca"/>
</reference>
<reference name="ReadInvoiceRecords">
<property name="jca.retry.count">
<replace>4</replace>
</property>
<property name="jca.retry.interval">
<replace>1</replace>
</property>
<property name="jca.retry.backoff">
<replace>2</replace>
</property>
<property name="jca.retry.maxInterval">
<replace>120</replace>
</property>
<binding type="jca"/>
</reference>
<reference name="GetSequence">
<property name="jca.retry.count">
<replace>4</replace>
</property>
<property name="jca.retry.interval">
<replace>1</replace>
</property>
<property name="jca.retry.backoff">
<replace>2</replace>
</property>
<property name="jca.retry.maxInterval">
<replace>120</replace>
</property>
<binding type="jca"/>
</reference>
<reference name="CallOracleAppsApi">
<property name="jca.retry.count">
<replace>4</replace>
</property>
<property name="jca.retry.interval">
<replace>1</replace>
</property>
<property name="jca.retry.backoff">
<replace>2</replace>
</property>
<property name="jca.retry.maxInterval">
<replace>120</replace>
</property>
<binding type="jca"/>
</reference>
<reference name="UpdateRejectionDateInHeaderTable">
<property name="jca.retry.count">
<replace>4</replace>
</property>
<property name="jca.retry.interval">
<replace>1</replace>
</property>
<binding type="jca"/>
</reference>
<reference name="UpdateBatchTableRejectionDate">
<property name="jca.retry.count">
<replace>4</replace>
</property>
<property name="jca.retry.interval">
<replace>1</replace>
</property>
<binding type="jca"/>
</reference>
<reference name="InvoiceFileInternalWrite">
<property name="InvoiceFileWrite">
<replace>/u50/app/SOA11G/IATA/MiscOutboundFiles/</replace>
</property>
<binding type="jca"/>
</reference>
<reference name="WriteZipFilesToLocal">
<property name="SISOutputFilesDir">
<replace>/u50/app/SOA11G/IATA/SISOutputFiles/InputDir/</replace>
</property>
<binding type="jca"/>
</reference>
</composite>
<wsdlAndSchema name="CallOracleAppsApi.wsdl|CallOracleAppsApi_db.jca|FetchHeaderAttachment.wsdl|FetchHeaderAttachment_db.jca|FetchLineAndTax.wsdl|FetchLineAndTax_db.jca|FetchLineAttachment.wsdl|FetchLineAttachment_db.jca|FetchLineRecords.wsdl|FetchLineRecords_db.jca|GetBatchId.wsdl|GetBatchId_db.jca|GetSequence.wsdl|GetSequence_db.jca|IndexInternalFileWrite.wsdl|IndexInternalFileWrite_file.jca|InsertAPInvoice.wsdl|InsertAPInvoice_db.jca|InsertErrorTable.wsdl|InsertErrorTable_db.jca|InvoiceFileInternalWrite.wsdl|InvoiceFileInternalWrite_file.jca|InvoiceInternalFileWrite.wsdl|InvoiceInternalFileWrite_file.jca|ReadAPInvoice.wsdl|ReadAPInvoice_file.jca|ReadBatchIdFromQueue.wsdl|ReadBatchIdFromQueue_apps.jca|ReadDetailErrorReport.wsdl|ReadDetailErrorReport_file.jca|ReadErrorReport.wsdl|ReadErrorReport_file.jca|ReadInvoiceRecords.wsdl|ReadInvoiceRecords_db.jca|ReadSISOutputFile.wsdl|ReadSISOutputFiles.wsdl|ReadSISOutputFiles_ftp.jca|ReadSISOutputFile_file.jca|ReadSummaryFile.wsdl|ReadSummaryFile_file.jca|ReadSummaryReport.wsdl|ReadSummaryReport_file.jca|ReadZip.wsdl|ReadZip_file.jca|sdcsd.wsdl|sdcsd_apps.jca|UpdateBatchInfo.wsdl|UpdateBatchInfo_db.jca|UpdateBatchTable.wsdl|UpdateBatchTableRejectionDate.wsdl|UpdateBatchTableRejectionDate_db.jca|UpdateBatchTable_db.jca|UpdateHeaderRejectionDate.wsdl|UpdateHeaderRejectionDate_db.jca|UpdateHeaderTable.wsdl|UpdateHeaderTableDate.wsdl|UpdateHeaderTableDate_db.jca|UpdateHeaderTableStatus.wsdl|UpdateHeaderTableStatus_db.jca|UpdateHeaderTable_db.jca|UpdateRejectionDate.wsdl|UpdateRejectionDateInHeaderTable.wsdl|UpdateRejectionDateInHeaderTable_db.jca|UpdateRejectionDate_db.jca|WriteSISOutputToLocal.wsdl|WriteSISOutputToLocal_file.jca|WriteZipFilesToLocal.wsdl|WriteZipFilesToLocal_file.jca|xsd/APInvoice.xsd|xsd/APPS_WF_EVENT_T_ReadBatchIdFromQueue.xsd|xsd/APPS_XXSIS_AP_TRX_PKG_CREATE_AP_TRX.xsd|xsd/APPS_XXSIS_POPULATE_TRX_PKG_GEN_SEQUENCE.xsd|xsd/APPS_XXSIS_POPULATE_TRX_PKG_UPDATE_BATCH_STATUS.xsd|xsd/APPS_XX_BPEL_RAISE_EVENT_WF_EVENT-24RAISE.xsd|xsd/AttachmentTransmissionV3.1.xsd|xsd/FetchHeaderAttachment.xsd|xsd/FetchLineAndTax_table.xsd|xsd/FetchLineAttachment.xsd|xsd/FetchLineRecords.xsd|xsd/GetBatch.xsd|xsd/GetBatchId.xsd|xsd/GetInvoiceRecords.xsd|xsd/IATA_IS_XML_Invoice_Standard_V3.1.xsd|xsd/IATA_IS_XML_Standard_Base_Datatypes_V3.1.xsd|xsd/IATA_IS_XML_Standard_Custom_Dictionary_V3.1.xsd|xsd/IATA_IS_XML_Standard_Main_Dictionary_V3.1.xsd|xsd/InsertErrorTable_table.xsd|xsd/IS-Validation-Detail-Error-Report.xsd|xsd/IS-Validation-Summary-Report.xsd|xsd/Params.xsd|xsd/ReadInvoiceRecords_table.xsd|xsd/Sequence.xsd|xsd/singleString.xsd|xsd/UpdateBatchInfo_table.xsd|xsd/UpdateBatchTableRejectionDate_table.xsd|xsd/UpdateBatchTable_table.xsd|xsd/UpdateErrorTable_table.xsd|xsd/UpdateHeaderRejectionDate_table.xsd|xsd/UpdateHeaderTableDate_table.xsd|xsd/UpdateHeaderTableStatus_table.xsd|xsd/UpdateHeaderTable_table.xsd|xsd/UpdateRejectionDate.xsd|xsd/UpdateRejectionDateInHeaderTable.xsd|xsd/UpdateRejectionDateInHeaderTable_table.xsd">
<searchReplace>
<search/>
<replace/>
</searchReplace>
</wsdlAndSchema>
</SOAConfigPlan>
Note:
i) In config plan, the properties can be added at composite level and replace the environment dependent values pertaining to that composite
ii) One or more composite properties can be referred in the config plan
Can have one config plan for each environment and refer config plan location appropriately in the build.properties
1.4 deployAll.bat / deployAll.sh
DeplyAll.bat (Windows)/ deployAll.sh (Linux) is the CMD script to run this ANT script. To make this work, we need ant-contrib library and put this in the local folder.
Below is the entries in deployAll.bat file
Note:
Setting the deployment.plan.environment while running the build.xml will overwrite the hard coded setting in the build.properties

Flow of Running ANT script:

Build.xml is the master file which will inturn call the build.parameters file to get the parameter values for each environment.
In build.properties, configplan.xml location is referred.

2. Pre-Running Steps

  1. Place the deployable SOA composites SAR files and config plans for each environment in a local folder
  2. Set the environment variables
2.1 Set JAVA_HOME – Set the path where JDK is installed and the folder should contain bin
For Eg: C:\Oracle\Middleware\jdk160_24
2.2 Set ANT_HOME - Set the path where the ANT is installed
For Eg: C:\Oracle\Middleware\modules\org.apache.ant_1.7.1
2.3 Set the path variable

  1. All the in built ant scripts are placed in the bin folder of oracle soa home - C:/Oracle/Middleware/Oracle_SOA1/bin
  2. Import the build.properties, build.xml and deployALL.bat to the soa home.
  3. Edit the build.properties and deployAll.bat/ deployAll.sh as per the environment
  4. And finally the CMD script to run this ANT script.

3. Running ANT Script

  1. Edit the deployAll.bat (Windows Env) / deployAll.sh (Linux Env) to set the deployment environment as dev/prod and run
(or)
open a command prompt and navigate to the build.xml folder and execute
ant -f build.xml deployAll -Ddeployment.paln.environment=dev


4. Verification Checklist

  1. Include a subset of test steps that will confirm that the customization has been installed properly.
Verify that the deployment has been properly done by following these steps:
a. Logging is enabled in the script. Look for logs in the Buildlogs folder

No comments:

Post a Comment