How Do I: Use an Existing Enterprise Java Bean?

WebLogic Workshop provides the EJB control to enable convenient access to an existing Enterprise Java Bean (EJB) from web services. To use an EJB, the client interfaces must be present in a JAR file in the WEB-INF\lib directory of the appropriate WebLogic Workshop project.

To Use an Existing Enterprise Java Bean

1. In WebLogic Workshop, open the project that will use the EJB.

2. If the WEB-INF\lib folder exists in the project, skip to step 5. If not, proceed to step 3.

3. In the Project tree, right-click the WEB-INF folder and select New Folder.

4. In the Enter a new folder name field, type lib, then click OK.

5. Copy the EJB JAR file from the to the WEB-INF\lib folder.

Once the EJB is included in your project, you can create a control to access to the EJB.

6. In WebLogic Workshop, open a web service that will use the EJB.

7. In Design View, from the Add Control drop-down list, select Add EJB Control. The Add EJB dialog appears.

8. Enter a variable name that your web service will use to reference the control member. It is customary for this name to start with an lower-case character. The name you enter must be a valid Java identifier.

9. Select Create a new EJB control to use with this service.

10. In the New CTRL name box, enter a name for the CTRL file. It is customary for this name to start with an upper-case character. The name you enter must be a valid Java identifier.

11. In the jndi-name field, type the Java Naming and Directory Interface (JNDI) name for your EJB, or click Browse to select one. Once you have selected an EJB by JNDI name, the home and bean interface text boxes should contain the names of the EJB's interfaces.

12. Click Create.

A CTRL file is created in the same directory as the web service to which it is being added, and a reference to that control is added to your web service. This control can now be used to access methods in the EJB. This CTRL file can also be used by other web services.

Related Topics

EJB Control: Using Enterprise Java Beans from a Web Service