Designer > About Interfaces Service References and Local WSDL > Creating a Java Interface
  

Creating a Java Interface

Process Developer provides an easy way for Java developers to use existing Java projects to build Java endpoints in a BPEL process. Your project can include a POJO (plain old Java object) or EJB. (A JavaBean can be used for all application servers except for Apache Tomcat). You can either start with or build a package that includes an interface and a Java class that implements the interface.
Using one of the techniques that Process Developer provides, you can automatically generate a WSDL and schema from your Java interface. The WSDL includes the port type, operation, and messages to create receives, replies, and invokes.
Process Developer also provides built-in features to automatically include all the JAR and other files required for deployment to the server.
Stateless or Stateful Invokes
Using the Java Interface, you can easily create invoke activities in BPEL. These invokes can be stateless or stateful.

Setting up Your Java Project in Process Developer

To create a Java interface for a BPEL process, you can start with an existing Java project or create a new Java-enabled orchestration project.
Setup a Java project a Java Project:
  1. 1. Select File > New > Orchestration Project.
  2. 2. Name your project and click Next.
  3. 3. Select Java Enabled Orchestration.
  4. 4. In the orchestration project, import or create a new Java Project. The Java project must contain:
Tip: If you have a Java project open in Eclipse, you can switch perspectives from the Eclipse Java Perspective to Process Developer. Then in the Project Explorer, right-mouse click on the project, and select Add Orchestration Nature.
When you add an orchestration nature to your Java project, a background validation builder ensures that you are aware of errors and problems in your process, imported WSDLs, and its other resources. Also, the builders automatically synchronize the generated WSDL with changes that might be made to the source Java.
After adding the Java project to Process Developer, you can generate a WSDL that is the BPEL-oriented interface needed to create activities. For details, see Generating WSDL and Schema from a Java Interface.
See also:

Constraints for your Java Project

The following requirements exist for Java classes used in a Java Interface implementation:
See also Creating a Java Interface.

Generating WSDL and Schema from a Java Interface

No WSDL? You can use the New Interface wizard as a quick start to generating the basics of a WSDL.
Generating WSDL and Schema from a Java Interface
Once you have set up your Java project in Process Developer's Project Explorer, you can generate WSDL and schema. A BPEL process requires a WSDL interface, and Process Developer automatically generates it from your Java interface.
Additionally, Process Developer automatically synchronizes the generated WSDL with any changes that you might make to the source Java.
To generate WSDL and schema:
  1. 1. In your Java orchestration project, create a new BPEL process in the bpel folder.
  2. 2. In Participants view, right-mouse click on Partner Service Provider and select New Partner Service Provider.
  3. 3. In the Partner Service Provider dialog, select Generate Interface.
  4. 4. In the New Interface wizard, select From a Java Interface.
  5. 5. Browse to your Java interface and select it.
  6. 6. Notice that the new WSDL is generated in the wsdl folder of your project.
  7. 7. Select Finish, and then select OK in the Partner Service Provider dialog.
WSDL Generation
The following actions occur when you generate a WSDL and schema from a Java interface:
The resulting WSDL contains the following constructs:
Schema Generation
More Ways to Generate WSDL and schema:
Technique to Generate WSDL
Result
In the Interfaces View, select the New Interface toolbar button.
The New Interface Wizard opens for you to select a Java Interface
In the Project Explorer, select the interface from your Java project. From the right-mouse menu, select Generate WSDL
WSDL and schema are generated in the location you select
From your Java project, drag and drop a Java interface method to the Process Editor canvas
The Create Activity wizard opens so that you not only generate WSDL and schema, you also create a new Web Services activity (such as a receive).
See also:

Generating Argument Names for Schema Elements

When you generate a WSDL file, as described in Generating WSDL and Schema from a Java Interface, a method’s argument are generated as schema elements. The elements have generic names, such as arg1_string, as shown:
<xs:element form="unqualified" name="arg1_string" type="xs:string"/>
You can generate schema elements with the actual argument names by adding a JAR file called ae_rt.jar to the project's Java build path list of external jars and adding annotations to your interface prior to generating the WSDL.
To generate argument names:
  1. 1. In the Project Explorer, right-mouse click on your project, and select Properties > Java Build Path.
  2. 2. Select the Libraries tab.
  3. 3. Select Add External JARs.
  4. 4. Browse to [Designer Installation]\designer\plugins\org.activebpel.enginep_[version_number]\server\shared\lib
  5. 5. Select ae_rt.jar, as shown:
  6. 6. Open your Java interface file and add the @AeWsdlParam annotation to each argument. For example:
  7. Public interface IMyInterface {
       public void execute(
       @AeWsdlParam("someValue") String someValue);
    }
  8. 7. Generate (or regenerate ) a WSDL by right-mouse clicking on a Java interface, and selecting Generate WSDL.
Process Developer generates the schema element with the argument name; for example:
<xs:element form="unqualified" name="someValue" type="xs:string"/>
Notes:

Updating Your Java Project and Your BPEL Process Concurrently

You can actively develop both the Java code that is being invoked and the BPEL that is invoking it. Process Developer regenerates the WSDL and schemas whenever the source Java interface or classes change. For example, if you add a new method to the Java interface, Process Developer automatically regenerates the generated WSDL and all generated schemas.
If the WSDL changes, you will see unresolved WSDL references indicators in your BPEL process. Error messages indicate the fixes you need to make for each activity using the WSDL.
See also Creating a Java Interface.

Deployment Requirements for a Java (POJO) Endpoint

Select the Java class that will be created and invoked at runtime.
For details on EJB Service, see Deployment Requirements for Java (EJB) Endpoint.
After you develop a BPEL process with a WSDL based on a Java interface, you're ready to deploy by creating JAR files. You will then provide deployment details specific to the Java interface. When you create the Process Deployment Descriptor (PDD) file for the process, you must provide details for the Java class that is created and invoked at runtime.
To provide required POJO deployment details:
  1. 1. Open the PDD Editor, as described in Creating a Process Deployment Descriptor File.
  2. 2. On the Partner Links tab, select the partner role that invokes the Java interface.
  3. Notice that the selection is set to Java Service for the invoke handler.
  4. 3. In the Java Invoke Handler Properties dialog, select the Java class that is created and invoked at runtime.
  5. 4. Select the Java classpath to be used when instantiating and invoking the Java class. The classpath includes not only the JAR (or local "src" workspace directory) that contains the class being invoked, but also any JARs that contain classes referenced directly or indirectly by that class.
  6. Note that the Inherit server classloader checkbox is selected by default. If you disable this option, you will only have access to the JARs on your classpath, not the JARs that are deployed to the server. You can also select Parent classloader last when inheriting Process Server classloader.
Deployment Details
When you select a Java invoke handler for the partner role implementing the Java interface, the Java resources are added to the resource catalog and deployed with the process. This includes all of the JARs included in the classpath.
Also, there is no endpoint reference information needed for a Java service.
See also Creating a Java Interface.

Deployment Requirements for Java (EJB) Endpoint

Select the Java class that will be created and invoked at runtime.
For details on setting up and designing a BPEL process with an EJB service, see Creating a Java Interface.
If you have developed a Web service implemented as an EJB, you can deploy the JAR files and other resources using the partner role invoke handler called EJB Service. Note that in the PDD Editor, the invoke handler detects your EJB project as a POJO and automatically selects Java Service. Be sure to select EJB Service.
Also note that an EJB Service cannot be used on Apache Tomcat. It is supported on other application servers.
The EJB Service handler performs a JNDI lookup to obtain the EJB home to instantiate the object used to call the method.
To fill in the EJB Service Invoke Handler Properties Dialog:
  1. 1. For a JNDI Name, specify the JNDI name as defined in your application server's EJB file, such as the JBOSS ejb-jar.xml file, the WebLogic weblogic-ejb-jar.xml file, or the WebSphere ibm-ejb-jar-bnd.xml file.
  2. 2. For EJB Home, specify the home interface as defined in application server's ejb-jar.xml file.
  3. This property is required for WebSphere, but is optional for JBoss and WebLogic.
  4. 3. In the Classpath box, select the Java classpath that is used when instantiating and invoking the Java class. The classpath includes not only the JAR (or local "src" workspace directory) that contains the class being invoked, but also any JARs that contain classes referenced directly or indirectly by that class.
  5. Note that the Inherit server classloader checkbox is selected by default. If you disable this option, you will only have access to the JARs on your classpath, not the JARs that are deployed to the server.
When you select an EJB invoke handler for the partner role implementing the EJB interface, the Java resources are added to the resource catalog and deployed with the process. This includes all of the JARs included in the classpath.
Also, there is no endpoint reference information needed for an EJB service.

Running a BPEL Process with a POJO EJB Endpoint

At runtime, when an invoke activity based on a Java endpoint executes, Process Developer invokes the Java method as follows:

Comparing the POJO EJB Interface to a Custom Java Invoke Handler

The Java Interface is designed for ease-of-use. A WSDL is generated for you and the JARs and other resources are automatically deployed in a BPR file. However, you must keep the Java project simple by following the requirements outlined in Constraints for your Java Project.
If your BPEL process requires custom Java code that handles asynchronous call-backs, policy assertions, and other details, you can use the Java wrapper custom invoke handler, as described in EJB/Java Invoke Handler Properties Dialog.