Using Property file in OSB to manage property data

Sometimes we may encounter the situation where you may need to carry some data (such as credential information or any other information) in a file so that the our client does not have to go to the actual code and do multiple or tricky changes as and when required.

In my case, I encountered a situation where I had to pass some fields in the target system service request payload such as userName, Password, CompanyCode

I had to put this information in the request payload along with other elements as well.
Now, my client wants me to put companyCode in a property file since as per he says CompanyCode's value will remain the same in all the request payloads and in case if they need to change the same in future then they could do the same without any much headache

Here I came up with the concept of property file which can very easily be implemented in OSB by two ways:-

1. XML Property file
2. XQuery property file

XML Property file is just a simple XML file which will hold all the properties needed in your project in an XML formatted file and you just need to read the required property(ies) out of this file and use wherever you need to.
Example:-
myPropertyFile.xml
------------------------
<properties>
 <UserName>username11</UserName>
 <Password>password11</Password>
 <companyCode>CC1111</companyCode>
 <clientip>127.0.0.1</clientip>
</properties>


Suppose you need to fetch the UserName and Password fields' data in a variable in OSB then just drag and drop an Assign action in a stage in request-pipeline
























It will populate whole xml into varPropertyDocData variable and after which you can use xpath to access UserName and Password elements

Example:-
$varPropertyDocData/*:properties/*:UserName/text()
$varPropertyDocData/*:properties/*:Password/text()

You can also directly apply this XPath while using above fn:doc function as given below:-

fn:doc('C:\Users\MahipalSingh\workspace\MyProject\Proxy_Services\myPropertyFile.xml')/properties/UserName/text()

````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````

XQuery property file is just a simple XQuery file having nothing but just a line
xquery version "1.0" encoding "Cp1252";
followed by an XML document.
Example:-
myPropertyFile.xq
------------------------

xquery version "1.0" encoding "Cp1252";
<properties>
    <UserName>username11</UserName>
    <Password>password11</Password>
    <companyCode>CC1111</companyCode>
    <clientip>127.0.0.1</clientip>
</properties>

 
 

Featured Post

How to create an AQ (Advanced Queue) on Oracle DB

Keywords: Advanced Queue, AQ, AQ Creation, Queue, Queue Creation, How to create a queue, Queue in SOA, SOA, OSB, BPEL -------------------...