Thursday, June 19, 2014

Running XQuery from Java applications using XQJ API - XQuery Processor for Java

Running XQuery from Java applications using XQJ API - XQuery Processor for Java

The purpose of this article is how to use xquery/xpath functions like fn:pare-xml, fn:sum etc in XQuery using java applications. 

This post shows the steps for running XQuery from java program using XQJ API - JSR 225: XQuery API for Java (XQJ).

XQJ allows a java application to connect to XML data sources and query the data using XQuery.

This is a simple order processing use case where order total was calculated based on product, price and order item quantity and discount was calculated based on customer type.

Product details and customer details are stored in XML source file. Customer type and discount values are stored in another XML source (config) file. 

Order details will be sent as a string to the XQuery so that fn:parse-xml (to convert string XML to structured form for processing) can be used to get the order element for processing in XQuery.

XQuery supports modules where common functions can be developed as modules and can be included in XQueries where ever they are required. 

The JAR files required for using the XQJ implementation from Oracle XDK are:
 xqjapi.jar, oxquery.jar, apache-xmlbeans.jar, xmlparserv2_sans_jaxp_services.jar 

Your application must run with Java version 1.6. 

 Above jar files are available from Oracle XQuery for Hadoop implementation

Download Oracle XQuery for Hadoop 2.4.1 from Oracle.

Steps:
  • Keep Jar files in JDeveloper class path:




  • Orderdetails XQuery


  • getOrder.xq XQuery: Usage of fn:parse-xml, fn:sum, fn:number, ora-fn:date-to-string-with-format, ora-fn:trim functions etc and also calling function getDiscount from module getDiscount.xq


  • getDiscount.xq XQuery:

  • Input XML: contains products and customer information


  • Discount config XML



  • Get Order Details class: XQJ API usage




Oracle XQuery  supports the
                XQuery 1.0,
                XPath 2.0 Functions and Operators and
                XQuery 3.0 features
                                group by clause
                                Standard functions         
                                                fn:serialize
                                                fn:parse-xml etc.
                Modules support (calling xquery from another xquery)

                The XQuery works properly in OSB environment and even in Eclipse OEPE
                fn-bea:inlinedXML fn-bea:date-from-dateTime

Utility functions:
The utility module contains ora-fn functions for handling strings and dates.
These functions are defined in XDK XQuery,
ora-fn - http://xmlns.oracle.com/xdk/xquery/function
String Functions
                ora-fn:pad-left
                ora-fn:pad-right
                ora-fn:trim
                ora-fn:trim-left
                ora-fn:trim-right

Duration, Date, and Time Functions
                ora-fn:date-from-string-with-format
                ora-fn:date-to-string-with-format
                ora-fn:dateTime-from-string-with-format
                ora-fn:dateTime-to-string-with-format
                ora-fn:time-from-string-with-format
                ora-fn:time-to-string-with-format


Download the above article sample code here


Resources

http://docs.oracle.com/cd/E16655_01/appdev.121/e17604/adx_j_xqj.htm
http://technology.amis.nl/2011/07/30/running-xquery-from-java-applications-using-the-xqj-api-and-the-oracle-xdk-implementation/
http://www.w3.org/TR/2014/REC-xpath-functions-30-20140408/



Wednesday, November 13, 2013

Installing Oracle SOA-BPM Release 11gR1 (11.1.1.7.0) (PS6), Oracle Service Bus (OSB) 11gR1 (11.1.1.7.0) and JDeveloper 11g (11.1.1.7.0) on Windows 7 64 bit

Installing Oracle SOA-BPM Release 11gR1 (11.1.1.7.0) (PS6), Oracle Service Bus (OSB) 11gR1 (11.1.1.7.0) and JDeveloper 11g (11.1.1.7.0) on Windows 7 64 bit



This blog describes how to install SOA-BPM Suite (including Oracle Service Bus) from scratch on Windows 7 64bit machine.


Step1: Downloading Required Software.


Go to Oracle SOA suite download page here.
Under Oracle SOA Suite 11g Installations, select release 11.1.1.7 and then Generic 64-bit JVM.


JDK 64 bits from Sun  jdk-6u27-windows-x64.exe
Database  - Oracle XE Universal - OracleXE112_Win32.zip
Oracle WebLogic Server 10.3.6 - wls1036_generic.jar
Repository Creation Utility 11.1.1.7.0 - ofm_rcu_win_11.1.1.7.0_32_disk1_1of1.zip    
SOA Suite 11.1.1.7.0 (2 parts)
  ofm_soa_generic_11.1.1.7.0_disk1_1of2.zip
  ofm_soa_generic_11.1.1.7.0_disk1_2of2.zip
Oracle Service Bus 11.1.1.7.0 ofm_osb_generic_11.1.1.7.0_disk1_1of1.zip
OEPE Windows All-In-One (x86 64-bit) oepe-indigo-all-in-one.zip
JDeveloper 11.1.1.7.0 Generic (jar)  jdevstudio11117install.jar
JDeveloper extension for SOA - download here


Create c:\stageFMW to hold the download files used for installation 

Step2: Installing the JDK.


JDK, SOA Suite, OEPE and OSB will be installing to the middleware home (C:\Middleware\ SOASuite11gR1PS6). If you use a different middleware home then adjust accordingly.
Provide folder name as C:\Middleware\ SOASuite11gR1PS6\JDK160_27 as shown below and install the JDK 64 bit
Click Ok.

















Click Next and finish

















Step 3: Installing Database:

Run file OracleXEUniv.exe and install the XE database. You may refer the Oracle XE installation guide.
After installing XE, run below commands to meet the requirements of SOA 11g installation –

connect sys/password as sysdba;
alter system set processes=500 scope=spfile;
shutdown immediate;











Start database.











If you are using Oracle XE as your database, you need to set the RCU_JDBC_TRIM_BLOCKS environment variable to TRUE prior to running RCU.

















Step 4: Install database schema using RCU


Run the Repository Creation Utility (RCU) to create the database schemas:













Click Next
















Enter the database information.



Ignore any warning messages during installation.
Select the component SOA and BPM Infrastructure. Dependent schemas are selected automatically.  



















Select the radio button to Use the same password for all schemas. Enter a schema password.




























Click Create to create the tables.




On “Completion Summary” page you should see success status for all the components you chosen.



















Step 5: Install WebLogic 10.3.6 Server 64 bits on windows


In a command window enter
Cd C:\stageFMW\Weblogic
java -D64 -Xmx1024m -jar wls1036_generic.jar




Click Next

Select Create a new Middleware Home and enter C:\Middleware\SOASuite11gR1PS6. If you use a different middleware home then adjust accordingly.


















Deselect the checkbox to receive security updates and Click Next.


(If you are behind firewall or using using proxy to connect internet then wizard may not show next window immediately. Deselect multiple times till you receive the below window.)
Select the check box as shown below to disable internet access.


 Select Typical installation and Click Next.


 As we downloaded the generic version of Weblogic, Select the installed JDK (C:\Middleware\SOASuite11gR1PS6\jdk160_27). 



Review the directories and Click Next.



 You will see the installation summary. Click next.


 Uncheck ‘Run Quickstart’ and Click Done when the installation completes.


Step6: Install SOA Suite – Base Components


In a command window enter (-jreLoc JDK installation location)
cd C:\stageFMW\SOA\Disk1
setup.exe -jreLoc C:\Middleware\SOASuite11gR1PS6\jdk160_27

(-jreLoc point to the JDK installation location)








Click Next.

















Skip software updates and click Next.

















Click Next. After the prerequisite check.

















On the Specify Installation Location screen, select the 
Middleware home: C:\Middleware\SOASuite11gR1PS6
 Accept the default Oracle home: Oracle_SOA1

















Click Next


















Accept the default on the Application Server page and click Next
Review summary
Click Install 


















Wait for the install to complete – takes a few minutes.

When install reaches 100%, click Next


















Click Finish

















Step 7: install OEPE


Unzip the oepe-indigo-all-in-one-11.1.1.8.0.201110211138-win32-x86_64.zip to the folder C:\Middleware\SOASuite11gR1PS6\oepe11118



Step 8: Service Bus installation


In a command window enter 
cd c:\stageFMW\OSB\Disk1 
setup.exe -jreLoc C:\Middleware\SOASuite11gR1PS6\jdk160_27










Click Next
















Select “Skip Software Updates” and click Next 


















On the Specify Installation Location screen, select the Middleware home: 
C:\Middleware\SOASuite11gR1PS6 
Accept the default Oracle home: Oracle_OSB1 


















For the installation type, select Typical and press Next.

















Click Next. After the prerequisite check.


















Select the OEPE location C:\Middleware\SOASuite11gR1PS6\oepe11118. Click Next and Install

















Once the installation process has finished, press the Next button

















The installation is now complete. Press the Finish button to exit the installer.

















Step 9: Create a SOA Developer Domain


In a command window enter
Cd C:\Middleware\SOASuite11gR1PS6\wlserver_10.3\common\bin
Config.cmd








When the configuration wizard welcome screen comes up, select Create a new WebLogic 
domain, click Next   Select “Generate a domain….“ and select 
a) Oracle SOA Suite for developers – 11.1.1.0 [Oracle_SOA1]: This automatically selects 
Oracle WSM Policy Manager – 11.1.1.0 [oracle_common] 
b) Oracle Enterprise Manager – 11.1.1.0 [oracle_common] 

Optional (dependant on the components you want to use): 
c) Oracle Service Bus for developers – 11.1.1.7 [Oracle_OSB1]: This automatically selects 
WebLogic Advanced Web Services for JAX-RPC Extension – 10.3.6.0 [wlserver_10.3] 
d) Oracle Business Activity Monitoring – 11.1.1.0 [Oracle_SOA1] 
e) Oracle BPM Suite for developers – 11.1.1.0 [Oracle_SOA1] 
f) Oracle JRF WebServices Asynchronous services – 11.1.1.0 [oracle_common]

Click Next 















Enter the domain name, e.g. soaosbps6devdomain and choose a location of your choice. Click Next
















 Enter user name weblogic and a password welcome1.

















Click Next
















On the Configure JDBC Component Schema screen, you select the components that you want to change, and then enter the property value for those components. 
First, select all of the components and enter password in the Schema Password field. 
Or, if you used a different password when you created the schema with RCU, enter that password.  With all of the check boxes still selected, enter the Service, Host, and Port values
















The data source connections are all tested.
If all are successful, click Next, otherwise click Previous and correct any errors.
















Click Next
















Click Next
















Uncheck the check box (start the admin server) and Click Done.

















Step 10: Installing JDeveloper and JDev SOA Extension

In a command window enter 
cd c:\stageFMW\JDev 
java -D64 -Xmx1024m -jar jdevstudio11117install.jar









Click Next
















Use existing middleware Home C:\Middleware\SOASuite11gR1PS6
















Error window will be displayed as shown below.












So select a new Middleware Home directory and provide Middleware Home Directory as  C:\Middleware\SOASuite11gR1PS6\JDev11gR1PS6   to proceed JDeveloper installation.
















Choose Install Type: Complete, click Next
  















Select the installed JDK (C:\Middleware\SOASuite11gR1PS6\jdk160_27). Click Next
















Confirm Product Installation Directories. Click Next
















Click Next
















Review Installation Summary. Click Next.
















Wait for the installation to complete – a few minutes. Click Next
















When installation completes, deselect Run Quickstart and click Done.

Start JDeveloper Studio 11.1.1.7.0 from the Windows Programs menu: Oracle Fusion Middleware 11.1.1.7.0

 or run C:\Middleware\SOASuite11gR1PS6\JDev11gR1PS6\jdeveloper\jdeveloper.exe









Select Default Role, de-select Always prompt for role selection on startup, and click OK















If you see the Confirm Import Preferences dialog click Yes or No as desired, usually No is appropriate.












Step 11:Update JDeveloper with latest SOA extension



Select Help/Check For Updates















Click Next
















Select install from local file.
Browse for file soa-jdev-extension.zip and open. 
Click Next 















Click Next and Finish.

Click Yes to restart the JDeveloper and finish the installation of the SOA extension.











Step 12:Starting servers

Start the Admin Server

Open command window and enter the command
Cd C:\Middleware\SOASuite11gR1PS6\user_projects\domains\soaosbps6devdomain\bin

startWeblogic.cmd







Admin Server console








Weblogic Admin console URL: http://localhost:7001/console
















Weblogic Enterprise Manager Fusion Middleware Control (EM) console URL: http://localhost:7001/em













Weblogic osb console URL: http://localhost:7001/sbconsole
















Start BAM Server

Open command window and enter the command
Cd C:\Middleware\SOASuite11gR1PS6\user_projects\domains\soaosbps6devdomain\bin

startManagedWeblogic.cmd bam_server1







Enter admin user credentials 
username weblogic  
password welcome1






BAM console











Open internet explorer and type the URL : http://localhost:9001/OracleBAM