Thursday, July 20, 2017

Hos to use Maven to deploy SOA 12c Composites

Prerequisites


JDK1.7
Apache Maven 3.0.5
Oracle Linux (you can try this in windows but I did it in Linux)
Oracle SOA 12.1.3 installed (you can use the quick start version of this as only libraries will be referenced)


Set the following environment variables 

JAVA_HOME
M2_HOME
ORACLE_HOME


Steps to set maven for SOA

Within Oracle SOA folder structure navigate to the maven plugins folder. In my case this was as follows: 
cd /home/oracle/Oracle/oracle_common/plugins/maven/com/oracle/maven/oracle-maven-sync/12.1.3

Install the soa plugins using the following maven command:
mvn install:install-file -DpomFile=oracle-maven-sync-12.1.3.pom -Dfile=oracle-maven-sync-12.1.3.jar

If you are behind a proxy this will fail but no worries still the .m2 repository folder will be created. 

Now if you were behind a proxy all you need to do is set the proper maven settings.xml configuration file. Create this within .m2 folder. In my case it was here --> /home/oracle/.m2

Below is an example of the settings.xml file.

<?xml version="1.0" encoding="UTF-8"?>
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.1.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <proxies>
    <proxy>
      <username>youusergoeshere</username>
      <password>passwordgoeshere</password>
      <port>yourproxyportgoeshere</port>
      <host>yourproxyhostgoeshere</host>
      <nonProxyHosts>localhost|127.0.0.0/8|localhost.localdomain|127.0.0.1|::1|testsoa|testsoa|10.0.2.15</nonProxyHosts>
    </proxy>
  </proxies>
  <profiles>
    <profile>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
    </profile>
  </profiles>
</settings>

Now you should be ready to populate your maven repository as follows (adjust paths according to your environment):
mvn com.oracle.maven:oracle-maven-sync:push -DoracleHome=/home/oracle/Oracle -Dmaven.repo.local=/home/oracle/.m2/repository

mvn help:describe -DgroupId=com.oracle.soa.plugin -DartifactId=oracle-soa-plugin -Dversion=12.1.3-0-0

You can use the following command to create a new SOA project
mvn archetype:generate -DarchetypeGroupId=com.oracle.soa.archetype -DarchetypeArtifactId=oracle-soa-application -DarchetypeVersion=12.1.3-0-0 -DarchetypeRepository=local -DgroupId=org.my.test -DartifactId=test-soa-application -DprojectName=test-soa-project -Dversion=1.0-SNAPSHOT

Also from within the app generated pom.xml folder you can execute
mvn clean  and  mvn package

When using jdeveloper choose import maven project and build your code, for example do mvn clean package from app pom.xml and the built project should be now in the target folder.

Deploying existing projects

Modify the pom.xml file (project pom not the application pom) as follows:

- Add the highlighted line
                        <scacInputDir>${scac.input.dir}</scacInputDir>
                  <!-- custom added for MAVEN -->
                    <appHome>${project.basedir}/..</appHome>
                    <input>${input}</input>


- Remove the word SNAPSHOT form <version>1.0-SNAPSHOT</version> to make it look as <version>1.0</version>

- Execute the following maven command to deploy to a specific server (change server name and credentials):
mvn pre-integration-test -DserverUrl=http://myhost.com:myport -Doverwrite=true -DforceDefault=true -Dcomposite.partition=mypartition -Duser=myuser -Dpassword=mypassword


Additional notes on projects referencing policies

 Modify the file /.m2/repository/com/oracle/adf/wsm-policy-core/12.1.3-0-0/wsm-policy-core-12.1.3-0-0.pom to look such as:

 <!--
Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.-->
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.oracle.adf</groupId>
  <artifactId>wsm-policy-core</artifactId>
  <version>12.1.3-0-0</version>
  <packaging>jar</packaging>
  <name>wsm-policy-core</name>
  <description>Generated from Oracle JDeveloper</description>

  <dependencies>
  <dependency>
            <groupId>com.oracle.adf</groupId>
            <artifactId>osdt_xmlsec</artifactId>
            <version>12.1.3-0-0</version>
  </dependency>
  <dependency>
  <groupId>com.oracle.adf</groupId>
  <artifactId>wsm-agent-core</artifactId>
  <version>12.1.3-0-0</version>
  </dependency>
  </dependencies>



Wednesday, April 8, 2015

Generate a Java SOAP web service client using netbeans 8.0 and JAXB

The following post details the steps I followed when creating a web service client I used to test a remote web service. The web service basically is an exposed Oracle Service Bus proxy service.  

1. Start by creating a new netbeans 8.0 project without any specifics.
2. Identify the location of the remote wsdl. In my case I'll will use a service I developed before in OSB (Oracle Service Bus) located at http://10.112.107.23:11001/EllieMaeNetwork_v1/CreditService/Proxy/CreditService_ps?WSDL
3. Within your project folder right click, go to new and then to web service client.



4. Fill in the WSDL URL and click finish. This will generate the custom stubs for your java client. However if there are issues in the schemas referenced in the remote WSDL the tool wsimport will throw an error. Some examples of these issues are duplicated xml schema types. If all was successful then continue on the section CODING THE REQUEST, otherwise continue on point (5).


5. In my case I got an error when generating the web service client stubs.



There are multiple approaches to resolve these conflicts being the easiest to modify the original XML schemas and make sure names are not duplicated.  But sometimes you can't do that cause you are not the owner of the service.  However you can either create custom binding files or add custom jaxb annotation elements to the xml schemas.  This jaxb annotations are not being added to the original XML schemas but to the imported XML schemas that live locally where netbeans is and/or your project is.  Netbeans uses a folder named xmlresources within the project folder to place the referenced WSDL and XSD schemas.

Examples of the changes I did to the XML schemas are as follows


Original schema header


Modified schema header


Note the jaxb header added on the modified header.


Second Example

Original enumerated type


Modified enumerated type


Note the added element jaxb:typesafeEnumclass element. This will tell XJC to use specific class names when generating JAXB objects.


Third Example

Original complex type


Modified complex type


Note the jaxb:class element being used to tell wsimport to generate the java class as ADOONTypeRequest opposed to the default name CREDITREPORTINGADDONType.

6. Once you have added your custom JAXB elements within the XML schemas you are ready to refresh the web service client in order to generate the proper java classes. While doing it make sure to uncheck the option "Also replace local wsdl file with original located at:



Now in the output window you will see a result similar to the following.



CODING THE REQUEST

1. On the web service references locate the operation of the remote WSDL (web service) you would like to invoke. In my case this was labeled as requestCredit . See below.


2. Click on the operation and drag it to the code area. This will generate the required default methods. In this case the method requestCredit got generated as follows.


3. The only left task is to create an instance of the object (CREDITREPORTINGREQUESTGROUPType for my case) used in the request and call the generated method (requestCredit for my case).



ADD A CUSTOM HEADER (this is optional)

This is not a mandatory step but sometimes some web services require the client to pass additional information in the SOAP header.  Examples of these items might be security tokens or elements needed when calling asynchronous web services.  In my case I'm calling an asynchronous web service therefore following the ws-addressing header definitions two items are being sent.  See below.


Note:  I won't discuss ws-addressing concepts in this post, at the moment all you need to know is how to add these elements to the SOAP header being sent.

To add these custom SOAP header we need to add a handler class and a handlerResolver class.  The handler will create the header elements and the HandlerResolver will link the handler to the original request.

Implemented java interfaces are
- javax.xml.ws.handler.soap.SOAPHandler for the handler and
- javax.xml.ws.handler.HandlerResolver for the resolver.

SOAPHandler:

HandlerResolver:

Finally add the handler resolver to the original request.  Below I show the original request code and just below the modified with the handler resolver added.

Original as
private static CREDITREPORTINGRESPONSEGROUPType requestCredit(com.elliemae.emvps.credit.CREDITREPORTINGREQUESTGROUPType input) {
        com.elliemae.emvps.credit.CreditBindingQSService service = new com.elliemae.emvps.credit.CreditBindingQSService();
        com.elliemae.emvps.credit.CreditEndPoint port = service.getCreditBindingQSPort();
        return port.requestCredit(input);
    }

Modified as

private static CREDITREPORTINGRESPONSEGROUPType requestCredit(com.elliemae.emvps.credit.CREDITREPORTINGREQUESTGROUPType input) {
        com.elliemae.emvps.credit.CreditBindingQSService service = new com.elliemae.emvps.credit.CreditBindingQSService();
//add the following to support the wsa05 addressing header
        HeaderHandlerResolver resolver = new HeaderHandlerResolver();
        service.setHandlerResolver(resolver);
        com.elliemae.emvps.credit.CreditEndPoint port = service.getCreditBindingQSPort();
        return port.requestCredit(input);
    }


Wednesday, August 13, 2014

Oracle Service Bus 12.1.3.0.0 (12c) Installation Guide

1 Required Software

·         Oracle Linux 6.2 (it is assumed this is already installed and an oracle account exists)
·         Oracle open jdk7 (jdk-7u55-linux-x64.rpm)
·         Oracle XE 11.2 database (oracle-xe-11.2.0-1.0.x86_64.rpm.zip)
·         Fusion middleware infrastructure (fmw_12.1.3.0.0_infrastructure.jar)

·         Fusion middleware service bus (fmw_12.1.3.0.0_osb.jar)


2 Installation steps (overview)

Oracle 12c service bus installation steps require diverse components to be installed in a series of steps. Details for each step will be added on the next sections, however the following items list the specific order to be followed when performing this installation.
·         Install JDK
·         Install Oracle database
·         Install fmw infrastructure
·         Install fmw service bus
·         Execute RCU database scripts
·         Create/Update weblogic domain
This guide will provide step by step instructions required when installing a development environment with only 1 admin server and 1 managed server. However these steps could easily be adjusted for 2 or more managed servers. Additionally in order to simplify this development environment, the database being used is Oracle XE which is not officially supported but works for this purpose.

3 Install JDK

Make sure you have downloaded oracle open jdk. Oracle edelivery site contains this and the rest of the required software components. If you get this jdk from oracle consider rpm packaging and extract as follows
                rpm -ivh jdk-7u55-linux-x64.rpm
now use the following commands to make this java your default
                alternatives --install /usr/bin/java java /usr/java/jdk1.7.0_10/bin/java 2
                alternatives --config java


test your java installation with java -version  , the command output should show something like
java version "1.7.0_55"
Java(TM) SE Runtime Environment (build 1.7.0_55-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.55-b03, mixed mode)

4 Install Oracle XE database


The XE database installation is really straightforward therefore just extract the rpm package with the command unzip oracle-xe-11.2.0-1.0.x86_64.rpm.zip, then navigate to the subdirectory Disk1 and then execute rpm -ivh oracle-xe-11.2.0-1.0.x86_64.rpm



The installation will ask you to execute the following command with root user. Open a different terminal window and execute with root user
/etc/init.d/oracle-xe configure
accept all the defaults except for the password, in my case I used oracle.



Now restart your system just to make sure Oracle XE is running when the system starts, and proceed to the next step.

5 Install fmw Infrastructure


execute the command java -jar fmw_12.1.3.0.0_infrastructure.jar


click ok to set the oracle inventory directory. Now set the middleware home, for simplicity in my case I used /home/oracle/Oracle/Middleware/Oracle_Home


For the installation type pick the option Fusion Middleware Infrastructure, at this moment we don't need the examples. Installation will check all the prerequisites are met. Check the remaining default options and then Install.


at the end you should see a successful screen as the following.


6 Install OSB

In a similar way as the infrastructure installation execute the osb software installation with a command as follows  java -jar fmw_12.1.3.0.0_osb.jar


 Click next to preserve the same oracle inventory directory. When asked for the oracle_home use the previously created oracle_home. In my case this is /home/oracle/Oracle/Middleware/Oracle_Home


Click next on the following default options until installation completes.


7 Execute RCU database scripts

Now that the infrastructure has been installed is time to create the corresponding database schemas.  Make sure JAVA_HOME variable is set, in my case this was set as
export JAVA_HOME=/usr/java/jdk1.7.0_10
Navigate to the directory [Oracle_Home]/oracle/common/bin and execute the rcu creation script as ./rcu


Click next and select create repository / System load and product load.
Now set the Oracle database XE connection parameters, make sure to use an oracle database account with sysdba privileges such as SYS.


Click next and then ignore the alert message acknowledging XE is not supported. This will still work, obviously for a production system use a fully supported Oracle database.
Select the database schemas shown below. You can use a different database prefix if you want, as long as you remember it at the moment of the domain creation.


click next and set the password to be used for each of these database schemas. In my case and for demonstration purposes I use oracle.


Now click next and accept to create the tablespaces.


Click on create and at the end a successful creation screen will show.


8 Create weblogic domain

The first thing is to create a generic weblogic domain that includes only OWSM and is only attached to the AdminServer. Don't create any managed server at this point.  To execute the shell script for the weblogic domain creation execute ./Oracle/Middleware/Oracle_Home/oracle_common/common/bin/config.sh
The first thing to do is set a domain name and location, in my case the domain name will be osbdomain and the location /home/oracle/Oracle/Middleware/Oracle_Home/user_projects/domains/osbdomain.


Now select the components to be installed for this domain, the below screenshot shows the detail. Also note Oracle Service Bus isn't selected. This will make sure OWSM is installed properly without messing up with OSB components.


click next and when asked for the domain credentials set them and take note for future references. In my case I used weblogic for user name and weblogic1 as the password.


Now select the option Development for domain type, also make sure jdk location is properly set and click next


On the next screen fill in all the database parameters and then click on Get RCU Configuration button.


click next and wait until all the database schemas have been tested. On the following screen select Administration Server and then next.


For the Administration Server configuration, fill in the listen address with your hostname in my case is osbhost. For the listen port you can use the default 7001. For the server groups choose JRF-MAN-SVR, WSM-CACHE-SVR, WSMPM-MAN-SVR.


Click next and then create. Wait until domain creation ends.


Now your domain is created and a successful screen will show up.


The domain can be verified by starting up the administration server with ./Oracle/Middleware/Oracle_Home/user_projects/domains/osbdomain/bin/startWebLogic.sh
Once it has started login with a web browser using a url following the pattern http://[hostname]:[listen port]/em such as http://osbhost:7001/em.  If your hostname and/or port is different use that instead.




9 Update weblogic domain to include OSB components

Before updating any weblogic domain make sure the Adminserver isn't running. To execute the shell script to update a weblogic domain do ./Oracle/Middleware/Oracle_Home/oracle_common/common/bin/config.sh
Note this script is the same used when the weblogic domain was initially created. On the first screen select the option update and select the domain previously created, in my case this is osbdomain.


Now select the osb required components as shown on the next screenshot.


click next and on the next screen the osbdomain database parameters should be populated. Confirm the values and click next.

click next in order to test the database connections.


click next and select the option managed servers, clusters and coherence.


Now fill in the osb server values such as osb server name (osb_server1 for me), listen address (osbhost for me), listen port (7003 for me). Also verify the group OSB-MGD-SVRS-COMBINED is chosen.


click next, skip cluster configuration due we are creating only one managed server. Click next and leave the default options for coherence clusters. On the Machine configuration screen click on the tab Unix Machine and then on the Add button. Fill in the unix machine settings. In my case I set LinuxMachine1 as machine name, osbhost as node manager listen address, and 5556 as node manager listen port.


Click next and on the following screen use the blue arrow to assign the servers to the unix machine.


Click on the update button and wait until domain finishes the updating process.


Domain successful update screen will show.


In order to test the domain first start the admin server from a linux terminal and then on a different terminal start the managed server. Use the following commands
./Oracle/Middleware/Oracle_Home/user_projects/domains/osbdomain/bin/startWebLogic.sh
./Oracle/Middleware/Oracle_Home/user_projects/domains/osbdomain/bin/startManagedServer osb_server1

Now login to the EM console in http://osbhost:7001/em and verify the installation.


10 Additional steps

·         When login into the weblogic domain console using a url such as http://osbhost:7001/console and clicking on deployments you will notice the following applications are shown with a warning symbol next to them. To fix this remove the AdminServer as a target for the following applications
o   Service Bus SFTP Transport Provider
o   Service Bus FTP Transport Provider
o   Service Bus Email Transport Provider
o   Service Bus File Transport Provider

Appendix A

Possible roadblocks and solutions
·         If the exception Too many open files is raised then edit /etc/security/limits.conf file and set hard and soft options for the oracle account, for example oracle           soft        nofile     50000.
·         if working in a virtualbox environment and access to shared folder for the oracle account is required. Use the root account to provide access as follows usermod -aG vboxsf oracle