Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


Eclipse Callisto Project Profile: Web Tools Platform : Page 3

The Web Tools Platform (WTP) is a powerful set of Eclipse add-ons that make Web application development with Eclipse easier and faster. Take a look under the hood and see how it can help you.


Working with Web Services

SOA architectures are becoming more and more prevalent in modern software development. Web services provide a widely adopted, standards-based approach to implementing an SOA architecture, effectively allowing heterogeneous systems to interact using a standard, XML-based protocol.

The WTP package provides some very useful tools for working with Web services based on the Apache Axis Web service libraries, for working with both Web services and Web service clients.

Central to the notion of Web services is the WSDL (Web Services Description Language), an XML document that precisely describes the services provided by a Web service. WTP provides a powerful graphical editor for WSDL files, built on the WTP XML editor (see Figure 6). Again, this will not exempt you from needing a decent knowledge of WSDL, but it will make life easier if you need to create, edit, or even just visualize WSDL files.

Click to enlarge

Figure 6. Editing a WSDL File Using WTP

Generating a Web service client is simple. All you need is the WSDL file that defines the service. Just create a new Web service client (File -> New -> Other -> Web Services -> Web Service Client) and provide the corresponding WSDL file. Your WSDL can be a local file, defined and maintained within your project, or a centrally maintained WSDL published on a Web site in your organization or elsewhere. Eclipse will create all the Java client classes you need to invoke the Web service, including the service endpoint interface, the service locator class, and the service-binding stub.

This approach is useful if you are working with a fairly stable Web service, such as a commercially provided service. If your Web service is being developed internally, as part of the same project as the client, you may need to consider a more dynamic approach, such as including the Web service client generation as part of the build process.

WTP also provides excellent support for writing, deploying, and testing your own Web services. The two approaches for building a Web service are generally known as bottom-up and top-down. In the bottom-up approach, you start off with a Java class implementing some business logic and let Eclipse automatically generate the WDSL file and associated classes to publish this business logic as a Web service. In the top-down approach, you start with a Web service definition (in the form of a WSDL file and corresponding XML schema) and generate the corresponding Java business class skeletons. In both scenarios, WTP provides powerful features to make the Web service developer's life easier. You can ask Eclipse to start up a Web server, deploy your Web service to it for tests, and monitor the SOAP messages going between the Web service and its clients.

Creating a Web service using the bottom-up approach is certainly the easiest way to get a Web service up and running quickly. Open the Web Service dialog (File -> New -> Other -> Web Services -> Web Service) and choose the bottom-up approach (see Figure 7). Then just specify the business class that you want to publish. You will be asked to indicate the methods you wish to publish, and then Eclipse will generate a corresponding WSDL file. If you asked, Eclipse would also start up a local application server of your choice and deploy the Web service to that server.

Click to enlarge

Figure 7. Creating a New Web Service

The first step in creating a top-down Web service is to identify the WSDL file. Open the Web Service dialog (File -> New -> Other -> Web Services -> Web Service) and specify the location of the WSDL file. As for the client, the WSDL file can be either a local file or on a remote server.

Next, Eclipse will generate an implementation skeleton class, along with a number of other low-level classes. The implementation class will contain empty business methods that you will need to provide. All the other nitty-gritty details have already been coded in other generated classes, which leaves you to concentrate on the business logic.

This approach is appropriate if you are using an externally defined WSDL. By leaving the WSDL file in your hands, it also allows you to keep better control over the exact data structures being used, which can help you avoid some subtle interoperability issues when working with .NET Web service clients, for example. The downside is the increased work involved in understanding, writing, and maintaining the WSDL file.

Configuring Your Web Server

Once you've written your J2EE application (or even just a bit of it), you will probably be eager to see how it performs on a real server.

WTP is designed to support a large number of both open source and commercial application servers out of the box. It currently supports 15 different application servers, ranging from the Jakarta Tomcat servlet container to full-fledged open source J2EE application servers such as JBoss, JOnAS, and Geronimo, as well as commercial applications servers such as BEA WebLogic and IBM WebSphere.

You add new server definitions in the "Server -> Installed Runtimes" window in the Eclipse Preferences screen (see Figure 8). You need to specify a JRE (you can use a different JRE for different application servers, if necessary) and the installation directory of your application server.

Click to enlarge

Figure 8. Setting Up a Server Configuration

Once you have configured your server, you can set it as the default server for your project in the project properties, or just select it explicitly when you run the application from within Eclipse.

Comment and Contribute






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