October 24, 2014
Hot Topics:
RSS RSS feed Download our iPhone app

Developing Web Services with Borland JBuilder Enterprise and BEA WebLogic Server

  • February 24, 2005
  • By Vlad Kofman
  • Send Email »
  • More Articles »

Exposing Code as a Web Service

For the demonstration purposes of wrapping existing "legacy" APIs and turning them into a fully functional Web service, consider an extremely simple Java class called Bean1 that has only three methods. One method always returns a random number, another a "Hello" string, and another a more complex object.

The class exposes a public API of just three methods, but a real-world application will contain a much more complex API. An enterprise application can have hundreds of methods returning values from databases, EJBs, or Mainframe call wrappers. Some methods will be taking parameters, others initiating a business transaction dialogue. But, it will be just as easy to convert any complex API into a Web Service API, as it is this sample class.

package beanexport;
import java.io.Serializable;

public class Bean1 implements Serializable {
   public double getDouble(){
      return Math.random();
   }

   public String getText(){
      return "Hello";
   }

   public Tuple getHeader(){
      Tuple t = new Tuple("Vlad","Kofman");
      return t;
   }

}

Please see Listing 1 for the Tuple object source.

Creating a Web Service

Assuming that the Bean1 Java project in JBuilder is set up and can be compiled successfully, and BEA Weblogic Server is up and running, the Bean1 class can now be exposed as a Web service. JBuilder truly simplifies the creation and deployment of any Web service. With the Bean1 project opened, follow these steps:

  1. Click Project -> Project Properties -> Server.
  2. Weblogic should be listed as one of the choices; choose it.
  3. Note: Web services can also be developed with JBuilder for deployment on a free Tomcat server; it appears here as a choice also.
  4. Additional configuration of services: A project will host on the chosen allocation server such as EJB. Servlets and JSPs can be selected as well, but for now, click OK.


  5. Click here for a larger image.

    Figure 3

  6. Click File -> New -> Web Services.
  7. Click New Web Service Configuration (JBuilder X).
  8. Choose Weblogic as toolkit, default is Axis (used with Tomcat server).
  9. Choose server and client modules.
  10. Create new Web Module; accept all defaults for now.
  11. Create new application module; also take all default values.


  12. Click here for a larger image.

    Figure 4

  13. In the next screen, name the server Bean1Server and save.

JBuilder automatically creates all necessary J2EE (Java 2 Enterprise Edition) standard folders and files structures. It should open a Web Services Designer view after the initial configuration is saved.

Now, for the easy part. The Bean1 project should have the following structure (left panel):

  • Package "beanexport"
  • ApplicationModule1 module
  • Web-services module
  • Web-services designers

Take the Bean1 class and drag-and-drop it on to the Web-services designers Area. Or, click the Create Service drop-down and choose Java Service.

Re-build the Bean1 project; more files should be auto-created in the different subfolder of the project. That is it; the Web service is done. All that remains is to deploy it!

Consider what JBuilder did.

After getting a class to expose, JBuilder will inspect all public APIs of the class and automatically generate a WSDL definition file and all SOAP stabs and proxies, package them into WAR and EAR files (more on these later), and prepare deployment descriptors specific to the application server selected.

Similarly, if Axis was to be chosen as a toolkit and Tomcat as a server, generated files would be specific for it also.





Page 2 of 4



Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Sitemap | Contact Us

Rocket Fuel