How Do I: Use Java Code From a Web Service?

Not all the classes you define with WebLogic Workshop need to be web services. You may create a regular Java class that you can use from your web services. If you wish to access a Java class from within a web service you may need to place an import statement at the top of your web service.

To Create a Java file

1. Click the File menu, point to New, then click New Java Class. The Create New File dialog appears.

2. Confirm that Java is selected.

3. In the File name field, type a name for the Java class you are creating.

4. Click OK.

Once you have created the Java file, you may create a Java class that performs whatever task you need. This Java class will not be a web service and the methods of this Java class will not be accessible to users of your web service.

To Use Existing Java Code

If you have existing Java code that you would like to call from your web service code, you merely have to place the Java code in the project. If you place source files (files with the .java extension) in the project, they will be compiled automatically when the web service that references the Java classes is built. You may also place compiled Java class files (files with the .class extension) in the WEB-INF\classes directory of the folder (in an appropriate directory hierarchy); or you may place a JAR file containing the classes in the WEB-INF\lib directory of the project.

Related Topics

Introduction to Java