Friday, 27 May 2016

Fetching abstract xpath using Count(bpws:getVariableData(....)) results in null error in SOA 11g





I am having one requirement where I need to fetch each productOrderItem from request but this element is not part of input schema type. It will be extended during runtime.



I have create BPEL2.0  Synchronous process and add one assign activity. Now I need to count productOrderItem node to a variable say count. But BPEL will not allow us to compile code with abstract path.


Solution: Use bpws:getVariableData() BPEL1.1 syntax or ora:countNodes

ora:countNodes('$inputVariable','payload','/client:customerDetails/client:productOrderItem')
OR
count(bpws:getVariableData('$inputVariable','payload','/client:customerDetails/client:productOrderItem'))

Test: After deployment open em console and paste below request

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body>
        <ns1:process xmlns:ns1="http://xmlns.oracle.com/POCs/AbstractpathProject/BPELProcess">
                                <ns1:OrderID>1111</ns1:OrderID>
                                <ns1:customerDetails>
                                                <ns1:customerId>1234</ns1:customerId>
                                                <ns1:orderStatus>Submitted</ns1:orderStatus>
                                                <ns1:orderSubStatus>Confirmed</ns1:orderSubStatus>
                                                <ns1:productName>D2H</ns1:productName>
                                                <ns1:productOrderItem>
                                                                <ns1:action>ADD</ns1:action>
                                                                <ns1:description>D2H Package</ns1:description>
                                                                <ns1:name>D2H Gold</ns1:name>
                                                                <ns1:objectType>Loyalty Package</ns1:objectType>
                                                                <ns1:productPrices>
                                                                                <ns1:productPrice>
                                                                                                <ns1:description>Loyalty Package</ns1:description>
                                                                                                <ns1:name>Loyalty Package</ns1:name>
                                                                                                <ns1:price amount="15.0">
                                                                                                                <ns1:currency>
                                                                                                                                <ns1:code>EUR</ns1:code>
                                                                                                                                <ns1:symbol>€</ns1:symbol>
                                                                                                                </ns1:currency>
                                                                                                </ns1:price>
                                                                                                <ns1:priceAlteration/>
                                                                                                <ns1:period>MONTHLY</ns1:period>
                                                                                </ns1:productPrice>
                                                                </ns1:productPrices>
                                                </ns1:productOrderItem>
                                </ns1:customerDetails>
        </ns1:process>
    </soap:Body>
</soap:Envelope>
Test result should have count of 1 for productOrderItem but getting zero

<count>
<count  xsi:type="def:string">0</count>
</count>

Solution: BPEL 2.0 done not support / in location.
Modify like below
OLD:ora:countNodes('$inputVariable','payload','client:customerDetails/client:productOrderItem')
NEW:ora:countNodes('$inputVariable','payload','/client:customerDetails/client:productOrderItem')
<count>
<count  xsi:type="def:string">1</count>
</count>
 


Monday, 8 February 2016

BPEL Continuous Integration Using Jenkins




This document describes the process of automation of deployment of BPEL code in jenkins that is checked in in SVN. The BPEL code along with deployment scripts (ant scripts used here) are to be checked into SVN. The Jenkins job configured will automatically check out and will deploy the code onto server


Pre-requisites
  o             Oracle SOA Environment (Installation) should be setup and running.
 o             SVN server and client should be installed and running.
 o             Java home should be set and java command is working from command prompt.
Procedure
     1.   Installation of Jenkins
·         Download Jenkins.war from http://jenkins-ci.org/content/thank-you-downloading-windows-installer and save in some location and install it.
·         Open Jenkins console using the url http://localhost:8080



 ·         Jenkins can be seen as a windows service in services.msc. It gets automatically started along with machine.

2. Configuration of MDS
 There are two way we can update the MDS.

  • Using FileMetadataStore to update the MDS with location directory structure.
  • Using DBMetadataStore(JIT DB) to update the MDS 


Now update the adf-config.xml file in SVN. Open the bpel project folder.





Copy the mds location= "D:\.....\trunk\soa\MdsXml\src"



Open adf.xml file and update as per your local mds location and committed back to SVN.


The below piece of code will help the project to refer to the local MDS/DB MDS.

<persistence-config>
        <metadata-namespaces>
          <namespace metadata-store-usage="mstore-usage_1" path="/soa/shared"/>
          <namespace metadata-store-usage="mstore-usage_2" path="/apps/xml"/>
        </metadata-namespaces>
        <metadata-store-usages>
          <metadata-store-usage id="mstore-usage_1">
            <metadata-store class-name="oracle.mds.persistence.stores.file.FileMetadataStore">
              <property value="${oracle.home}/integration"
                        name="metadata-path"/>
              <property value="seed" name="partition-name"/>
            </metadata-store>
          </metadata-store-usage>
          <metadata-store-usage id="mstore-usage_2">
<!--CI integration enabled JIT file based MDS -->
            <!--metadata-store class-name="oracle.mds.persistence.stores.file.FileMetadataStore">
 <property value="D:\........\trunk\soa\MdsXml\src"
                        name="metadata-path"/>
            </metadata-store-->
                <!--CI integration enabled JIT DBbased MDS -->
             <metadata-store class-name="oracle.mds.persistence.stores.db.DBMetadataStore">
              <property value="PE1_SOA_MDS" name="jdbc-userid"/>
              <property value="******" name="jdbc-password"/>
              <property value="jdbc:oracle:thin:@host:port/SID" name="jdbc-url"/>
              <property value="soa-infra" name="partition-name"/>
            </metadata-store>
          </metadata-store-usage>
        </metadata-store-usages>
      </persistence-config>

 3.   Deployment structure


Create folder structure for script deployment as shown in the picture below.
    
BPEL
  |  ---Trunk
              |----SOA
                    |--Project1
                           build.xml    //single project build file which point to generic_build
                           Pom.xml    //project level POM file maven build
                            Config
                               generic_build.xml
                               Adf-config.xml
                               properties_DEV.properties //DEV Server connectivity details
                               wlserver_cfgplan.xml

  • Adding Project1/Build.xml

<?xml version="1.0" encoding="windows-1252" ?>
<project default="compile" basedir=".">
<!-- Run with ant -Doracle.home=<Oracle home directory> -->
<!-- ant is found in /u01/appl/weblogic/soa111160/modules/org.apache.ant_1.7.1/bin/ant -->
<!-- oracle home directory is /u01/appl/weblogic/soa111160/SOA1 -->
<property name="compositeName" value="<projectName>.customer"/>
  <import file="config/generic_build.xml"/>
</project> 

  •        Adding Project1/Config/generic_build.xml

<?xml version="1.0" encoding="windows-1252" ?>
<project default="compile" basedir=".">
<property name="overwrite" value="true"/>
<property name="revision" value="1.0.0"/>
<property name="environment" value="DEV"/>

<!--property file="${basedir}/config/properties_${environment}.properties"/ -->

<target name="compile">
  <mkdir dir="SCA-INF/classes/META-INF"/>
  <copy todir="SCA-INF/classes/META-INF" file="config/adf-config.xml" overwrite="true"/>

  <ant antfile="${oracle.home}/bin/ant-sca-package.xml" inheritall="false">
      <property name="compositeDir" value="${basedir}"/>
                <property name="compositeName" value="${compositeName}"/>
      <property name="revision" value="${revision}"/>
             </ant>
</target>

<target name="release" depends="compile">
       <property name="sarLocation" value="sca_${compositeName}_rev${revision}.jar"/>
                   <mkdir dir="${release.dir}"/>
                   <copy todir="${release.dir}" file="deploy/${sarLocation}"/>
</target>

<target name="deploy-dev">
        <property file="${basedir}/config/properties_${environment}.properties"/> 
        <property name="overwrite" value="true"/>
                   <antcall target="deploy"/>
</target>

<target name="deploy-it">
          <property file="${basedir}/config/properties_${environment}.properties"/> 
          <property name="overwrite" value="true"/>
                   <antcall target="deploy"/>
</target>

<target name="deploy"  depends="compile" >
          <echo>Deploying Project: ${compositeName}</echo>
          <echo>basedir: ${basedir}</echo>
          <property name="sarLocation" value="sca_${compositeName}_rev${revision}.jar"/>
          <ant antfile="${oracle.home}/bin/ant-sca-deploy.xml" inheritall="false">
              <property name="serverURL" value="${server.url}"/>
              <property name="sarLocation" value="${basedir}/deploy/${sarLocation}"/>
              <property name="user" value="${server.user}"/>
              <property name="password" value="${server.password}"/>
              <!-- property name="configplan" value="${basedir}/config/${server.configplan}"/-->
              <!--This project do not required configplan file -->
              <property name="partition" value="${server.partition}"/>
              <property name="overwrite" value="${overwrite}"/>
          </ant>
</target>

<target name="package">
     <property name="sarLocation" value="sca_${compositeName}_rev${revision}.jar"/>
                   <copy todir="${basedir}/deploy" overwrite="true" >
                             <fileset dir="${basedir}/config" includes="wlserver*, build.xml" />
                             <filterset>
                                      <filter token="SCAFILE" value="${sarLocation}"/>
                             </filterset>
                   </copy>
       <zip destfile="${basedir}/deploy/${compositeName}_rev${revision}.zip">
          <fileset dir="${basedir}/deploy" includes="${sarLocation}, wlserver*, build.xml" />
      </zip>
</target>
</project> 

  •     Adding properties_DEV.properties
#Wed Aug 07 15:23:03 CET 2015
server.url=http\://172.16.76.216\:10101
server.user=weblogic
server.partition=default
server.password=welcome1
server.configplan=<if required>

  • Adding pom.xml
     In MAVEN, each project should have a project.xml in the root folder. It defines the project object model of each project. The POM is defined in a pom.xml file that contains all the information necessary to build the project, generate reports and configure plugins.

     groupId - the group name under which this Artifact/project will be grouped
artifactId - the unique name of the artifact that would be generated by the project.
name - name of the Application
currentVersion - version number of the Application
packaging - Source package
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
       <modelVersion>4.0.0</modelVersion>
          <parent>
              <artifactId>soa.parent</artifactId>
                   <groupId>com.<projectName>.soa</groupId>
                   <version>1.0.0</version>
          </parent>
          <artifactId><projectName>.customer</artifactId>
    <version>1.0.1</version>
    <packaging>pom</packaging>
          <name>Customer SOA Composite</name>
</project>

·         Deployment:
 Navigate to the below path in command prompt (or go to the below path in file explorer and shift+right click, click the option open the command window here ).
<path>\soa
    Run the below maven command for build
Syntax:  mvn clean install -Doracle.home=<jdeveloper_installed_path>
Ex: mvn clean install -Doracle.home="D:\Oracle11.6\Middleware\jdeveloper"

Run the below ant command for deployment
Syntax:ant -Doracle.home=<jdeveloper_installed_path> <target env>
Ex:ant -Doracle.home="D:\Oracle11.6\Middleware\jdeveloper" deploy-dev

4. Configuration of Jenkins for Automatic Deployment

Open the URL: http://localhost:8080/ and click on manage Jenkins->Configure system


Configure the ant,SVN,maven path like below. Ant is coming with oracle Jdeveloper installer.
Like, Ant_Home =D:\Oracle11.6\Middleware\jdeveloper\ant



JAVA_HOME= D:\Oracle11.6\Middleware\jdk160_24




If you have a Freestyle project with a "Invoke Top Level Maven Targets" build step, you can add the appropriate JVM switches for a given build by clicking the Advanced button on the build step and entering the JVM arguments in the JVM Options field.
Alternatively, you can affect all free style Maven build steps by adding a MAVEN_OPTS global environment variable in the Jenkins global configuration. To do this, click Manage Jenkins, then Configure System. In the Global properties section, click the Environment Variables checkbox, then add a new environment variable called MAVEN_OPTS with the value set appropriately:
Set MAVEN_OPTS= -Xmx512m -XX:MaxPermSize=512m



Download and install apache-maven-3.0.4 version or the latest one and set the Maven home path to path variable
M2= D:\apache-maven-3.0.4



To create a new project in Jenkins, click on ‘New Item’ in Dashboard.



 Give ‘Item Name’ as <project>.customer and select Build a free style software project and click OK.


Add build steps.
Use maven command for compile/build in jenkins.

Select “Invoke Top Level Maven Targets” with maven version for build.
 M2= clean install -Doracle.home="D:\Oracle\Middleware11.6\jdeveloper", Save it.
Use ant command for deploy to server.
ant -Doracle.home="D:\Oracle11.6\Middleware\jdeveloper" deploy-dev
Here we defined multiple build target. 


Save the configuration and build now.


Then click on console output.



We can see in console page first Build and then deployed the service to DEV server.


Similarly we can deploy all the BPAL project.



Reference(s)