Developing Web Services with Borland JBuilder Enterprise and BEA WebLogic Server
At the present, most of the corporate world is either entertaining an idea of Web service infrastructure or is actively developing it. Honestly, it is not that difficult to leverage previously written business logic and expose it as a Web service. Web service standards have gained a lot of momentum in the past years and now have come to the point where they are reliable and robust; even different development toolkits will produce standardized results across different platforms.
There are several advantages to adding a Web service infrastructure to any business process. First, an existing source code (PC or mainframe based) and all the investment that went into its development will not vanish, but in fact will continue to serve its purpose from behind a new Web interface. Second, new business transactions will be easy to conduct over the Web and they will interact with any new or legacy system that is also exposed as a standard Web service. Third, business transactions become meaningful, thanks in part to the SOAP and XML standards. Fourth, if a Web service is well designed, process control should become minimized. Fifth, the session is done over HTTP connection and therefore potentially may not be limited by firewalls. There are of course other benefits for implementing Web services and they are therefore a very good ROI for any corporation.
In this article, I will explain how to create a simple Web service from an existing Java application using enterprise-level tools, such as JBuilder X or JBuilder 2005 Enterprise and BEA WebLogic Application Server. I will describe the structure, standards, and logic of a Web service and the platforms involved. To demonstrate a Web service in action, a project with a server and a client will be created. The client will initiate a real Web service session to the server. I will also briefly describe how to accomplish the same, by using freely available tools such as Eclipse IDE and Axis Toolkit.
To have a working Web service, an Application Server capable of hosting it to the world is required. A,Web service also may be optionally registered with any public UDDI (Universal Description, Discovery, and Integration) registry or with a local UDDI registry hosted on an application server. The UDDI provides address book functionality to the potential business clients; it allows the client to locate a particular service and describes what kind of APIs are available. Without the UDDI registry, business clients can (and often will) go directly to a Web service URL and request a WSDL (Web Service Definition Language) document that also will contain a detailed description of what APIs are provided. The WSDL is an XML document that is hosted by the Application Server.
In a true business environment, WSDL should define not only all methods that are available but also a schema for all transactions. WSDL is designed to be understood by Web Service programs to help them create object stubs with methods to call on the client-side; a WSDL file is therefore auto generated by the toolkit that will be used to create a Web service.
A Web Service will be hosted as a Web application, inside of a web service container on an Application Server. Any interested client will initiate a regular HTTP session to interact with it. To set up Web service, Bea WebLogic Application server will be used, which is one of the industry leading platforms. It is available for free for development purposes, but for a production environment it will require a license. As an alternative, a free Tomcat application server and Axis toolkit or Jetty application server and Axis toolkit can be used. There are other Application Servers, notably JBoss, SunOne from Sun Microsystems, and WebSphere from IBM, but they are beyond the scope of this article. Any of these Web platforms are capable of hosting a Web application and services. For the development side, JBuilder X or 2005 Enterprise provides tremendous flexibility and ease in creating Web services. I also highly recommend the free Eclipse IDE with WebSphere or IBM WSAD tool for creating Web services hosted on WebSphere application server, but they are beyond the scope of this article.
Installation of BEA Weblogic is very straightforward, but JBuilder needs to be configured to hook into the Application server. Directions are as follows: In JBuilder, under the Tools menu, click Configure Servers to set up an application server setting.
Figure 1: Set up Custom parameters for the server.
Creating a Legacy Project
Create a new project in JBuilder. Create a new "beanexport" package in that project and add one class called Bean1. Another class called Tuple (see Listing 1, at the end of this article) can be created as well. The tuple class holds a pair of strings and is used to demonstrate a more complex object sent via a Web service. It is completely optional and does not need to be used.