Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

Create a portable Web service in multiple J2EE environments

Ivy Ho, Software developer, IBM
Ivy Ho is a software developer working on the IBM WebSphere Studio Application Developer XML Tools team at the IBM Toronto Lab. Specifically, she is responsible for the Web Service Interoperability Cheatsheet, which helps users create a WS-I-compliant Web service. Previously, she was a member of the WebSphere Commerce runtime team, handling some of WebSphere's attachment features; she was also the migration team lead. For technical questions about the content of this tutorial, contact the author, Ivy Ho, at ivyho at ca.ibm.com.
Derek Koo, Software engineer, IBM
Derek Koo, P.Eng., is a software engineer working on the IBM WebSphere Studio Application Developer Server Tools team at the IBM Toronto Lab. Specifically, he is responsible for the J2EE Publishing Server and the Static Web Server. Previously, he was a member of the VisualAge for Java WebSphere Tools team, and was the component owner of the Servlet SmartGuide in VisualAge for Java Version 3.5. You can contact the co-author, Derek Koo, at dkoo at ca.ibm.com.

Summary:  This tutorial shows how to create a portable end-to-end Web service in multiple J2EE environments with the IBM WebSphere Studio Application Developer 5.1.1 Web Service wizard. The Web service client and server application code are generated with different runtimes and EARs. The Web service is deployed to a remote server.

Date:  28 Oct 2005
Level:  Introductory PDF:  A4 and Letter (2223 KB | 55 pages)Get Adobe® Reader®

Activity:  2338 views
Comments:  

Introduction

What's this tutorial about?

In the real world of business, all of a company's systems do not always come from a single vendor. The best-of-breed approach, in which organizations select the best tool for each specific job, makes more business sense, as it offers more flexibility to fit the different needs of a company. Often organizations will have servers running remotely and one or more clients talking to those servers. For instance, a company might have WebSphere Application Server running on an Unix box and multiple clients running on Windows machines using WebSphere Studio as a development environment. Some smaller companies with limited budgets might run WebSphere Studio on Windows clients but run other application servers, like JBoss, on Linux hardware at the server end.

Vendor-independent software development is crucial to ensure that companies have cost-effective integration that meets their needs and does not limit their choice of system configurations. The Web services model's loose coupling is the key to flexible, inexpensive integration capabilities. Web services clients and servers are totally separate components, potentially supporting different runtime protocols and running on different servers. The WebSphere Studio Web Service wizard provides us with all the necessary tooling to deliver such vendor-independent Web service solutions.

This tutorial demonstrates how to use IBM WebSphere Studio Application Developer Version 5.1.1 (hereafter just called WebSphere Studio) to generate a Web service from a JavaBean component using Apache Axis as the server runtime. (Since Web services are a relatively new concept, developing a new Web service for an existing application - the "bottom-up" approach - will likely be the least expensive. That's why we'll be using a JavaBean component as the basis of our service.) You'll also learn how to generate the client proxy using WebSphere Application Developer V5.1 as a client runtime, and see a sample application that tests the Web service using the WebSphere Test Environment. The tutorial then shows you how to deploy the application onto the open source JBoss application server (version 3.2.1 integrated with Tomcat Version 4.1.12) by using WebSphere Studio's J2EE Publishing Server, and invoking the Web service from WebSphere Studio.

The Web service you'll build will have the following features:

  • The Web service client runtime can be the same as or different from the server application runtime.
  • The Web service client and server have different EAR files.
  • The Web service server application will be deployed to a remote server, such as JBoss.
  • The Web service client and server run on different J2EE servers - for instance, the client could run on IBM WebSphere and the server on JBoss.

Our tutorial's Web service, called the Body Mass Index service, will calculate your body mass index based on the height and weight you enter, and return a weight status (Overweight, UnderWeight, Normal, or Obese) in a string. You will also generate the client proxy and sample application using WebSphere Studio's Web services wizard and test it in the WebSphere runtime test environment.

You will test the generated proxy using Web service JSP pages. The proxy can be launched in a Web browser at the following URL:

http://localhost:port/WebProjectClient/sample/
 WebServiceProxyName/TestClient.jsp

You can use this sample application to test the Body Mass Index Web service by selecting the method bmindication(), entering values for the parameters weight_in_pounds and height_in_inches, and clicking Invoke. The weight status string result will be displayed in the results pane of your browser.

Then we will configure the server and deploy the Web service using WebSphere Studio's J2EE publishing server, and run it on the JBoss server. By switching the endpoint of the Web service via the sample Test Client application, we can test the Web service on the JBoss server.

After completing the tutorial, you will know how to efficiently use WebSphere Studio tools to develop, test, deploy, publish, and discover a Web service. Along the way, you'll pick up some extra tips and tricks on what to do for a Web service that has different client and server runtimes. You'll also learn how you can easily deploy Web services using WebSphere Studio's J2EE Publishing Server tools with other J2EE-compliant servers, and to easily switch inside WebSphere Studio to test Web services with different servers.


Prerequisites

You don't need to be familiar with Web services programming to take this tutorial, but you should have Web application development experience. You should also know basic Java language programming. Previous experience with WebSphere Studio would be helpful but is not required.


Our system configuration

Here are the system configurations for the client and server runtimes we will use in this tutorial:

  • Client runtime: WebSphere V5, running on the WebSphere Studio 5.1.1 server test environment
  • Server runtime: Apache Axis 1.0, running on the JBoss server

The image below illustrates our setup:



Figure 1. System configuration
Figure 1. System configuration

You can have these two runtimes on the same machine or different machines, depending on your preference. Since the client and server runtime are different, we will create one Web project for the client and another for the server. There will be two EAR files as well, one for client and one for server. This will make the application more portable.


The J2EE Publishing Server

The J2EE Publishing Server is one of the features of the server toolset in WebSphere Studio Application Developer Version 5.0. This new server type lets you develop J2EE applications, deploy them to remote J2EE-compliant servers that require minimal configuration (such as Apache, Tomcat, or JBoss), and then test the client applications from the WebSphere Studio workbench.


Download the sample code



Figure 2. Sample code
Figure  2. Sample code

In this tutorial, you will create and configure the J2EE Publishing Server so that you can deploy the Body Mass Index Web service to the JBoss application server. In the Download section, you will find a link to ws-j2eewscode.zip; this contains the Java source file for the Body Mass Index JavaBean component. You should download it to a drive on your computer. A folder called BMISource will be created when you unzip it.

1 of 7 | Next

Comments



Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=SOA and Web services
ArticleID=137455
TutorialTitle=Create a portable Web service in multiple J2EE environments
publish-date=10282005
author1-email=
author1-email-cc=
author2-email=
author2-email-cc=

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere).

My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Try IBM PureSystems. No charge.