Creating and Deploying SOA Composite Applications with Maven


Options



Before You Begin

Purpose

This tutorial shows you how to create a SOA composite application with Maven and then deploy it to Oracle SOA Cloud Service.

Time to Complete

45 minutes

Background

Many development organizations are adopting iterative development methodologies to replace the older waterfall-style methodologies. Iterative, agile development methodologies focus on delivering smaller increments of functionality more often than traditional waterfall approaches. To accomplish this, organizations tend to adopt a Continuous Integration practice.

Build automation is one of the advantages of Continuous Integration, and Maven is one of the main tools for build automation. Maven is included with Oracle Fusion Middleware.

Using this tutorial, you can learn how to generate Maven artifacts to create SOA composite applications and then deploy them to your local environment and to Oracle SOA Cloud Service. You also learn how to set up a Secure Shell(SSH) tunnel to your cloud instance to deploy your applications by using Maven commands.

Context

This is the sixth OBE of a series that shows you how to install Oracle SOA Suite 12c, develop and test SOA composite applications and Oracle Service Bus applications from the start, and deploy the same applications to Oracle SOA Cloud Service.

What Do You Need?

Installing the Oracle Maven Synchronization Plug-In

  1. Open a command-line shell and verify that you have an installed version of Maven:

    > echo $M2_HOME
    Note: The output should be empty if Maven wasn't configured before.
  2. Set the M2_HOME environment variable to point to Apache Maven in your Oracle home directory, and add the Maven bin directory to the PATH environment variable: 

    Your path definition should be formatted something like the following:

    > export M2_HOME=$ORACLE_HOME/oracle_common/modules/org.apache.maven_3.0.5
    > export PATH=$M2_HOME/bin:$PATH
    
  3. Navigate to $ORACLE_HOME/oracle_common/plugins/maven/com/oracle/maven/oracle-maven-sync/12.1.3, and run the following command to install the plug-in into your local Maven repository: 

    > mvn install:install-file -DpomFile=oracle-maven-sync-12.1.3.pom -Dfile=oracle-maven-sync-12.1.3.jar
    

    The BUILD SUCCESS message is displayed:

    [INFO] Installing /scratch/user_home/Oracle/Middleware/Oracle_Home/oracle_common/plugins/maven/com/oracle/maven/oracle-maven-sync/12.1.3/oracle-maven-sync-12.1.3.pom to /scratch/user_home/.m2/repository/com/oracle/maven/oracle-maven-sync/12.1.3-0-0/oracle-maven-sync-12.1.3-0-0.pom
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESS
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 11.027s
    [INFO] Finished at: Thu Aug 06 14:52:42 PDT 2015
    [INFO] Final Memory: 8M/144M
    [INFO] ------------------------------------------------------------------------

    Note: If you have connection issues, set a proxy in your /home/user_home/.m2/settings.xml settings file. Add the proxy element with your proxy configuration and try to install the plug-in again:

    <settings>
    .
     <proxies>
      <proxy>
        <id>example-proxy</id>
        <active>true</active>
        <protocol>http</protocol>
        <host>proxy.example.com</host>
        <port>8080</port>
        <username>proxyuser</username>
        <password>somepassword</password>
        <nonProxyHosts>www.google.com|*.example.com</nonProxyHosts>
      </proxy>
    </proxies>
    .
    </settings>
    
  4. Seed the Oracle SOA Suite 12c development Maven plug-in into the Maven local repository:

    > mvn com.oracle.maven:oracle-maven-sync:push -DoracleHome=$ORACLE_HOME -DtestingOnly=false -DoverwriteParent=true
    
  5. Validate whether you successfully installed the plug-in by using the Maven help:describe goal:

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

Generating Maven Artifacts

  1. In the command-line shell, navigate to the directory where you want to create your project:

    > cd /scratch/user_home/jdeveloper/mywork/mvn_projects
  2. In the command-line shell, generate the Maven artifacts:

    > mvn archetype:generate 
      -DarchetypeGroupId=com.oracle.soa.archetype 
      -DarchetypeArtifactId=oracle-soa-application 
      -DarchetypeVersion=12.1.3-0-0 
      -DgroupId=org.mycompany 
      -DartifactId=my-soa-application 
      -Dversion=1.0-SNAPSHOT 
      -DprojectName=my-hello-world-soa-project

    Note: You need to format the previous command in a single line before execution.

  3. Verify that the project was created:

    [INFO] project created from Archetype in dir: /scratch/user_home/jdeveloper/mywork/mvn_projects/my-soa-application
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESS
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 18.850s
    [INFO] Finished at: Thu Aug 06 15:28:25 PDT 2015
    [INFO] Final Memory: 16M/204M
    [INFO] ------------------------------------------------------------------------
    

Importing a Maven Project into JDeveloper

  1. In JDeveloper 12c, from the main menu, click File, and then Import.

    File menu in JDeveloper
    Description of this image
  2. In the Import dialog box, select Maven Project, and click OK.

    Import dialog box
    Description of this image
  3. On the Import Maven Projects page, select Browse to Maven Project's Root directory, and click OK.

    Import Maven Projects page without selections
    Description of this image
  4. On the Choose Directory page, go to the directory where the project was created, select my-soa-application, and click Select.

    Choose Directory page
    Description of this image
  5. On the Import Maven Projects page, select pom.xml and Also import source files into application, and click OK.

    Import Maven project page with the selected pom files
    Description of this image
  6. On the Create Application page, verify the application name, select a directory where you want to import the project, and click OK.

    Create Application page with the application name and directory
    Description of this image

    Note: You can select the same location where the project was created and override all files, or you can select the default workspace of your SOA projects.

  7. On the Applications tab, verify that my-hello-world-soa-project was created.

    Applications tab in JDeveloper with the project structure
    Description of this image

Adding a Business Process Execution Language (BPEL) Process

  1. On the SayHello page, drag and drop a BPEL Process component from the Components palette to the Components swimlane (column).

    Empty my-hello-world-soa-project page
    Description of this image
  2. On the Create BPEL Process page, in the Name field, enter MakeGreeting.From the Template list, select Synchronous BPEL Process, and click OK.

    Create BPEL Process page with the Synchronous BPEL Process
    Description of this image
  3. After the BPEL and SOAP Service components are created, examine the MakeGreeting and makegreeting_client_ep components on the SayHello page.

    my-hello-world-soa-project page with a BPEL Process and Proxy Server components
    Description of this image

Editing a BPEL Process

Adding an Assign Activity

After you've added the BPEL process, you edit it to add the Assign activity.

  1. On the SayHello page, right-click the MakeGreeting BPEL component and select Edit.

    MakeGreeting BPEL Proncess menu
    Description of this image
  2. On the MakeGreeting.bpel page, from the Basic Activities panel, drag and drop the Assign activity to the Main Process sequence, between receiveInput and replyOutput.

    MakeGreeting.bpel page
    Description of this image
  3. Examine the Assign activity. By default it has the Assign1 name and shows a warning.

    MakeGreeting.bpel page with an Assign activity named Assign1
    Description of this image

Editing the Assign Activity

After you've added the Assign activity, you can edit it to build the output message.

  1. On the MakeGreeting.bpel page, right-click the Assign1 activity and select Edit.

    Assign1 right-click menu
    Description of this image
  2. On the Edit Assign page, click the Expression icon.

    Edit Assign page
    Description of this image
  3. On the Expression Builder page, in the String Functions panel, select concat, and click Insert Into Expression.

    Expression Builder page with the String Fuctions displayed
    Description of this image

    The concat()function appears in the Expression panel.

    Expression with the concat empty function
    Description of this image
  4. Enter 'Hello ', between the parentheses of the function.

    Expression with the concat function including a Hello string
    Description of this image
  5. In the Expression panel, leave the cursor active after the comma. In the BPEL Variables panel, expand inputVariable, payload, and client: process, select client:input string, and click Insert Into Expression.

    client:input string BPEL variable selected
    Description of this image
  6. Verify your expression, and click OK.

    Expression Builder page with the complete expression
    Description of this image

    The Edit Assign page displays the function in the Drag panel.

  7. In the right panel of the Edit Assign page, expand outputVariable client:MakeGreetingResponseMessage(x), payload and client:processResponse, and then drag and drop the function from the Drag panel to the client:result string.

    Edit Assign page with a expression dragged to the result string
    Description of this image

    The function wires (connects) the client: input string from inputVariable and the client:result string from outputVariable.

    Edit Assign page with the wired variables
    Description of this image
  8. On the General tab, enter Assign_Greeting in the Name field, and click OK.

    General tab with a custom name for the Assign activity
    Description of this image

    The Edit Assign page closes and the MakeGreeting.bpel page appears again.

  9. Verify that your MakeGreeting.bpel page contains the Assign activity.

    Makegreeting.bpel page with the updated Assign activity
    Description of this image
  10. In JDeveloper, click Save All.

    Save All button from the main menu
    Description of this image

    The SayHello project is ready for deployment.

Deploying a SOA Composite Application to a Local Environment

Deploying the Maven Project

  1. In the command-line shell, navigate to your Maven project:

    > cd /scratch/user_home/jdeveloper/mywork/my-soa-application
    
  2. In the command-line shell, build and deploy the SOA project to the local server, and then verify that the build succeeded:

    > mvn pre-integration-test 
    -DoracleServerUrl=http://localhost:7101
      -DsarLocation=deploy/sca_my-project_rev1.0.sar 
      -Doverwrite=true 
      -DforceDefault=true 
      -Dcomposite.partition=default 
      -Duser=weblogic 
      -Dpassword=welcome1

Testing the Maven Project in the Local Environment

  1. In your  web browser, enter the URL for Oracle Enterprise Manager Fusion Middleware Control in the following format:

    http://hostname.domain:7101/em
  2. On the Login page, enter your credentials and click Login.

    Fusion Middleware Control Login page
    Description of this image
  3. In the Target Navigation pane, expand SOA, soa-infra, and default, and then click my-hello-world-soa-project [1.0-SNAPSHOT].

    Target Navigation pane displaying the default partition from soa-infra
    Description of this image
  4. On the my-hello-world-soa-project [1.0-SNAPSHOT] page, click Test.

    my-hello-world-soa-project[1.0-SNAPSHOT] home page
    Description of this image
  5. On the Test Web Service page, click the Request tab and expand Input Arguments. Under SOAP Body, expand payload, enter Maven Project in the input field, and then click Test Web Service.

    Test Web Service page with the user input
    Description of this image
  6. Click the Response tab, and verify that the response displays your input.

    Response tab with the Hello Maven Project message
    Description of this image

Deploying a SOA Composite Application to Oracle SOA Cloud Service

After you've created the SOA composite application and project, you deploy the project to Oracle SOA Cloud Service by using a Maven command.

Setting SSH Tunnels

  1. Download the private key file (opc_rsa) of your Oracle SOA Cloud Service instance to your file system.

  2. In the command-line shell, go to the location where you downloaded the private key file and set the proper permissions:

    > chmod 600 opc_rsa
    
  3. In the command-line shell, create the SSH tunnel to the Administration Server, replacing the two 0.0.0.0 strings with the public IP address of the cloud instance.

    > ssh -v -i opc_rsa -L 7002:0.0.0.0:7002 opc@0.0.0.0 -N
    

    Note: Make sure that the port number corresponds to the Administration Server.

  4. In another command-line shell, create the SSH tunnel to the Managed Server, replacing the two 0.0.0.0 strings with the public IP address of the cloud instance.

    > ssh -v -i opc_rsa -L 8001:0.0.0.0:8001 opc@0.0.0.0 -N
    

    Note: Make sure that the port number corresponds to the Managed Server.

  5. In your web browser, enter the URL for Fusion Middleware Control in the following format:

    http://localhost:7002/em
  6. On the Login page, enter your credentials and click Login.

    Fusion Middleware Control login page
    Description of this image

    You successfully accessed the remote Fusion Middleware Control by using the localhost address.

    Fusion Middleware Control domain home page
    Description of this image

Deploying the Maven Project to Oracle SOA Cloud Service

  1. Make sure that the SSH tunnels are open before running the Maven command.

  2. In the command-line shell, navigate to your Maven project:

    > cd /scratch/user_home/jdeveloper/mywork/my-soa-application
    
  3. In the command-line shell, update the server URL to deploy the SOA application to Oracle SOA Cloud Service:

    > mvn pre-integration-test 
      -DoracleServerUrl=http://localhost:8001
      -DsarLocation=deploy/sca_my-project_rev1.0.sar 
      -Doverwrite=true 
      -DforceDefault=true 
      -Dcomposite.partition=default 
      -Duser=weblogic 
      -Dpassword=welcome1
  4. Verify that the application is deployed to the cloud instance through the SSH tunnel.

    INFO: Creating HTTP connection to host:localhost, port:8001
    INFO: Received HTTP response from the server, response code=200
    ---->Deploying composite success.
    [INFO]
    [INFO] ------------------------------------------------------------------------
    [INFO] Building my-soa-application 1.0-SNAPSHOT
    [INFO] ------------------------------------------------------------------------
    [INFO] ------------------------------------------------------------------------
    [INFO] Reactor Summary:
    [INFO]
    [INFO] my-hello-world-soa-project ........................ SUCCESS [10.332s]
    [INFO] my-soa-application ................................ SUCCESS [0.000s]
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESS
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 12.976s
    [INFO] Finished at: Mon Aug 10 09:47:56 PDT 2015
    [INFO] Final Memory: 18M/327M
    [INFO] ------------------------------------------------------------------------

Testing the Maven Project in Oracle SOA Cloud Service

  1. In your web browser, enter the URL for Fusion Middleware Control in the following format:

    https://localhost:7002/em
  2. On the Login page, enter your credentials and click Login.

    Fusion Middleware Control login page including weblogic credentials
    Description of this image
  3. In the Target Navigation pane, expand SOA, soa-infra (DefaultServer), and default, and then click my-hello-world-soa-project [1.0-SNAPSHOT].

    Target Navigation pane displaying my-hello-world-soa-project [1.0-SNAPSHOT]
    Description of this image
  4. On the my-hello-world-soa-project [1.0-SNAPSHOT] page, click Test.

    my-hello-world-soa-project [1.0-SNAPSHOT] home page
    Description of this image
  5. On the Test Web Service page, click the Request tab and expand Input Arguments. Under SOAP Body, expand payload, enter Maven From Cloud in the input field, and then click Test Web Service.

    Test Web Service page with the input user
    Description of this image
  6. Click the Response tab, and verify that the response displays your input.

    Response page with the string result
    Description of this image

Want to Learn More?

Credits

  • Lead Curriculum Developer: Armando Hernandez