Friday, 31 May 2013

Ant script deployment for BPEL


In this tutorial I will explain how BPEL interfaces can deploy in unix environment using shell script.
But before that you need to set all the path.



Create on setWLSEnv.cmd file where set all the path or individually set all these path in comment promt.

set ORACLE_HOME=C:\oracle\Middleware
set ANT_HOME=%ORACLE_HOME%\jdeveloper\ant
set PATH=%ANT_HOME%\bin;%PATH%
set JAVA_HOME=%ORACLE_HOME%\jdk160_24


after setting path echo the path.

Now back to the command prompt.
Check ant exists or not

But if you want to permanently set the path ,use environment variable to set it

A sample project has been to created to print an input message from a Asynchronous BPEL. The user gives input through the client.

Before deployment I can configure a deployment plan xml file.
Right Click on composite.xml file and Generate config plan.

Appending env name:dev
A file generates name <projectName_cfgPlan_env.xml>.

Env may be dev,test,prod according to your need.

This configuration can be attached at the time of deployment. You can change properties of the project with the configuration plan.

Add two files (build.properties, build.xml) in the same project of the JDeveloper (.Jca Project).
Sample files is given with the document.


build.properties
build .properties file contain all the environment related path and port details.
There should be one build .properties for each environment.Here  

# build file for HelloWorldComposite
proj.composite.name=HelloWorld
# revision of the composite
proj.composite.revision=1.0
# Simply specify Java Home
java.home =C:/Oracle/Middleware/jdk160_18/bin
#Project directory
proj.compositeDir=C:/JDeveloper/mywork/HelloApps/HelloWorld
# Set oracle.home to <JDEV_HOME>/jdeveloper, where <JDEV_HOME> is JDEV # installation directory
oracle.home=C:/Oracle/Middleware/jdeveloper
# soa-server side oracle home directory - needed for deployment plans
# and the weblogic sca library deployment
soa.server.oracle.home=C:/Oracle/Middleware/Oracle_SOA1
#################Deployment server connection information########################
# the admin server connection information
admin.server.host=localhost
admin.server.port=7001
# the domain where soa infra is installed
server.domain.name=soa_domain
# connection information for the managed server, used for soa-deployment
managed.server.host=localhost
managed.server.port=8001
# User and credentials for the servers
server.user=weblogic
server.password=Welcome1
# wls server where soa is targeted.
server.targets=soa_server1
deployment.plan.environment=dev

build.xml

<?xml version="1.0" encoding="UTF-8" ?>
<project name="SoaWSProject">
  <!-- build.properties --> 
   <property file="build.properties"/>
  <property name="deploy.dir" value="${proj.compositeDir}/deploy"/>
  <echo>deploy.dir :${deploy.dir}</echo>
   <target name="build">
    <property name="sca-inf.classes.dir" value="../SCA-INF/classes"/>
       <mkdir dir="${sca-inf.classes.dir}"/>
      <ant antfile="${oracle.home}/bin/ant-sca-package.xml" target="package" inheritall="false">
        <property name="oracle.home" value="${oracle.home}"/>
        <property name="compositeDir" value="${proj.compositeDir}"/>
               <!-- needed for adf config -->
         <property name="scac.application.home" value="${basedir}/../.."/>
         <!-- name of the composite -->
        <property name="compositeName" value="${proj.composite.name}"/>
         <!-- revision of the composite -->
        <property name="revision" value="${composite.revision}"/>
         <!-- java.passed.home passed to scac, this property will be
             overwritten to the env.JAVA_HOME if such env variable is defined in OS level-->
         <property name="java.passed.home" value="${java.home}"/>
    </ant>
  </target>
  <target name="deploy">
     <echo>Deploying to http://${managed.server.host}:${managed.server.port}/soa-infra/deployer</echo>
     <echo>proj.compositeDir :$(proj.compositeDir)</echo>
            <echo>composite.name :${composite.name}</echo>
            <echo>java.home :${java.home}</echo>
            <echo>deploy.dir :${deploy.dir}</echo>
    <ant antfile="${oracle.home}/bin/ant-sca-deploy.xml" target="deploy" inheritall="false">
        <!-- reformat of prop names -->
         <property name="user" value="${server.user}"/>
        <property name="password" value="${server.password}"/>
        <!-- create the url for deployment -->
        <property name="serverURL" value="http://${managed.server.host}:${managed.server.port}/soa-infra/deployer"/>
         <!-- location of the sar -->
        <property name="sarLocation" value="${deploy.dir}/sca_${proj.composite.name}_rev${composite.revision}.jar"/>
         <!-- force overwrite if already there -->
        <property name="overwrite" value="true"/>
        <property name="forceDefault" value="true"/>
         <!-- configplan-->
        <property name="configplan" value="${proj.compositeDir}/${proj.composite.name}_cfgplan_${deployment.plan.environment}.xml"/>
    </ant>
<echo>sarLocation :${sarLocation}</echo>
 </target> 
</project>

Now run the build.xml file to build the project.I am using "ant build" commend.Here is build
After compilation you have to deploy the project




Saturday, 25 May 2013

Add/Rename/Remove Namespace



In this tutorial I have tried to capture some xquery operation namespace.We are having lot many issues with these namepace.Sometimes source xml does not have any namespace.So middleware need to add those namespace and send it to target system with expected format.

Here I am creating one OSB proxy service with will poll messages from jms queue using jms transport protocol.Messages are xml type with no namespace.


I am using xquery to addnamespace with that input xml.

xquery version "1.0" encoding "Cp1252";
(:: pragma parameter="$noNamespaceXML" type="xs:anyType" ::)
(:: pragma parameter="$namespaceURI" type="xs:string" ::)
(:: pragma type="xs:anyType" ::)
declare namespace xf = "http://tempuri.org/Resources/XQueries/addNamespace/";
declare function addNamespaceToXML($noNamespaceXML as element(*),$namespaceURI as xs:string)as element(*)
{
 element {fn:expanded-QName($namespaceURI,fn:local-name($noNamespaceXML))}
{
      $noNamespaceXML/@*,
      for $node in $noNamespaceXML/node()
      return
      if (exists($node/node())) then addNamespaceToXML($node,$namespaceURI)
      else if ($node instance of element()) then element {fn:expanded-QName($namespaceURI,fn:local-name($node))}{$node/@*}
      else $node }
};

declare variable $noNamespaceXML as element(*) external;
declare variable $namespaceURI as xs:string external ;
addNamespaceToXML($noNamespaceXML, $namespaceURI)

Proxy message flow I am using replace activity to replace the existing input body with this xquery and adding log after that to display the change body.


To Test this,I am putting input xml in jms queue.

<?xml version="1.0" encoding="UTF-8"?>
<empDetails>
<emp>
<empID>1111</empID>
<empName>Souvik</empName>
<empaddr>2020 GOVERNMENT AVE,NORTH DAKOTA</empaddr>
<sal>10000</sal>
</emp>
</empDetails>



Here is output with namespace alias xmlns:emp="http://www.example.org/EmpDetails".


After adding namespace to request message I am renaming the namespace from "http://www.example.org/EmpDetails" to "http://www.souviksoa.com/EmpDetails"
I am using rename activity here.I xpath using .//* to rename all child elements under body.


Here is the next output


Now I am removing namespace using xquery or xslt.


xslt transformation for remove namespace


xquery transformation for remove namespace

xquery version "1.0" encoding "Cp1252";
(:: pragma  parameter="$anyType1" type="xs:anyType" ::)
(:: pragma  type="xs:anyType" ::)

declare namespace xf = "http://tempuri.org/Cancel_Order/Remove_Namespace/";

declare function xf:strip-namespace($e as element())as element()
{element { xs:QName(local-name($e)) }
{ for $child in $e/(@*,node())
 return  
 if ($child instance of element())
    then xf:strip-namespace($child)
       else $child
       }
 };

declare variable $e as element() external;
xf:strip-namespace($e)


Final output after removing the namespace.