Skip Headers
Oracle® Fusion Applications Developer's Guide
11g Release 1 (11.1.3)

Part Number E15524-03
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

38 Invoking Custom Java Code from a SOA Composite

This chapter describes what a SOA composite application needs to do to invoke logic implemented by a Java class.

When to implement: A SOA composite application needs to invoke logic implemented by a Java class.

Design Pattern Summary: The logic is accessed using a web service that the SOA composite component accesses directly. The logic can be placed within an existing ADF Business Components service, or the Java class can be published as a web service.

Involved components:

38.1 Introduction to the Recommended Design Pattern

While the most common implementation of business logic will either be inside the application module of a business component or in a SOA composite application, Oracle Fusion applications may contain business logic implemented in a separate Java class. A SOA composite component within the application may need to access this logic. When the logic has some relation to the entity or view objects defined in a business component, it is best to implement the logic as another service method on the component. You can publish the business component as a service, and the SOA component can access the logic through that service.

In some cases, the application does not contain a business component that accesses the same data as the logic in the Java class. In this case, you can publish the class as a web service, allowing the SOA component to directly access the logic through the service.

38.2 Other Approaches

Instead of accessing the logic through a SOAP binding, you could use a BPEL component with a Java activity to invoke some custom Java code.

An alternative is to use the bpelx:exec command to programmatically call Java methods. This is the same as using a Java activity, only without a UI. It is recommended to use the bpelx:exec command to complete light tasks such as the following:

WARNING:

Do not use the bpelx:exec command to access the application database or a SOAP service.

To access the application database, use a JCA database adapter. To access a SOAP service, use a BPEL Invoke activity.

For more information about using the bpelx:exec command, see the chapter "Incorporating Java and Java EE Code in a BPEL Process" in the Oracle Fusion Middleware Developer's Guide for Oracle SOA Suite.

Another alternative is to call custom Java classes using custom XPath functions. For more information about using XPath functions to call a Java class, see the sub-section "Creating User-Defined XPath Extension Functions" in the appendix "XPath Extension Functions" in the Oracle Fusion Middleware Developer's Guide for Oracle SOA Suite.

38.3 Example

Download the sample code for this use case from the following location. Oracle SOA Suite samples.

38.4 How to Invoke a Java Class from a SOA Composite Application

Instead of directly accessing the Java class, you can add the logic to a business component and then publish the business component as a SOAP service. The SOA composite application component accesses the ADF Business Components service, which in turn invokes the Java code.

To use a business component:

  1. Create a business component, including the required logic as a method on an application module, as documented in the section "Part II: Building Your Business Services" of the Oracle Fusion Middleware Fusion Developer's Guide for Oracle Application Development Framework.

  2. Generate the service interface for the business component and from the SOA component, invoke the service through a SOAP binding, as described in Chapter 35, "Orchestrating ADF Business Components Services."

38.5 Securing the Design Pattern

You secure this design pattern in the same way as you secure a pattern that has an ADF Business Components service invoked from a SOA composite application. For details, see Section 35.5, "Securing the Design Pattern."

38.6 Verifying the Deployment

To properly verify this design pattern, you should test your business component, then deploy and test the SOA composite application.

To verify this design pattern:

  1. Test your Oracle ADF application using various testing and debugging methods described in the chapter "Testing and Debugging ADF Components" of the Oracle Fusion Middleware Fusion Developer's Guide for Oracle Application Development Framework. For information about testing the ADF Business Components service, see the chapter "Integrating Web Services Into a Fusion Web Application" in the Oracle Fusion Middleware Fusion Developer's Guide for Oracle Application Development Framework.

  2. Deploy the SOA composite application to the standalone WLS where the SOA infrastructure has been installed. Because you created a published event from the SOA composite application to the ADF Business Components service, the ADF Business Components service need not to also be deployed to the SOA infrastructure.

  3. Test the deployed SOA composite service using Oracle Enterprise Manager Fusion Middleware Control Console. Every deployed service has its own test page, so you can quickly test that the service functions as you expect. For more information about using the Fusion Middleware Control Console to test deployed SOA composite applications, see the following chapter:

    "Automating Testing SOA Composite Applications" in the Oracle Fusion Middleware Developer's Guide for Oracle SOA Suite.

38.7 Troubleshooting the Use Case

Following are tips that may help resolve common issues that arise when developing or running this use case.

When writing custom Java code, you may need to use logging messages for debugging. You can then monitor the log files for troubleshooting information.

For more information about testing and debugging, see the following chapter:

"Testing and Debugging ADF Components" in Oracle Fusion Middleware Fusion Developer's Guide for Oracle Application Development Framework.

38.8 What You May Need to Know About Invoking Custom Java Code from a SOA Composite

If you have already created a business component and the method semantics of the needed logic fit with the other service methods already implemented in the application module, you should add another method for the needed logic to the application module. If the method relies on entity and or view objects on the business component, then adding the method to the business component is the only approach available.

If you have not created a business component or the method semantics do not fit with the other service methods already implemented in the application module, you may want to create a Java web service instead.