Interoperability is the key to using Web services architecture since many applications can collaborate to maximize business functions. With the capability of creating an application on a different architecture, including the application architecture, hardware infrastructure, and even the operating system, Web service architecture is the bridge to optimizing the IT Department.
In this article we will create a simple Web service using an EJB application and we will create a Flash MX project as a Web service client interface. We will use Websphere SDK v5.0.1 for the server-side scenario and Macromedia Flash MX 2004 for the client side. The complete source code for this article can be downloaded from www.sys-con.com/websphere/sourcec.cfm.
Prerequisites
You will need the Windows system that installed Macromedia Flash MX 2004, and you will also need an operating system (Windows or Linux) on which you have installed WebSphere SDK Web Service 5.0.1.
Server-Side Scenario
Creating a Simple Web Service from an EJB Application
First, create the J2EE Enterprise Application Project - for this article, we named it MATHServices.
Next, open J2EE Perspective from Window > Open perspective > other > J2EE. Then open J2EE Hierarchy and expand the EJB Modules; you will see the MATHServicesEJB Project as shown in Figure 1.
Create the Session Enterprise Bean at MATHServiceEJB Project (MathOperation)
Create the session enterprise bean called MathOperation and enter the following properties (see Figure 2):
- Bean name: MathOperation
- Source folder: ejbModule
- Default package: com.math.service
public String ApplicationInfo(String strUserName) { return "Hello " + strUserName + " Welcome to Math Operation Service"; } public Integer Multiply(Integer a, Integer b) { return new Integer(a.intValue() * b.intValue()); } public Integer Add(Integer a,Integer b) { return new Integer(a.intValue() + b.intValue()); } public Integer Substract(Integer a, Integer b) { return new Integer(a.intValue() - b.intValue()); }
Now you are ready to move to the outline perspective and promote ApplicationInfo, Multiply, Add, and Subtract method to the remote interface (see Figure 3).
Finally deploy the code for the MathOperationEJB (see Figure 4).
Generate a Web Services WSDL
Expand MathOperationEJB and right-click MathOperation session bean and start Web Services > Generate WSDL File (see Figure 5).
Enter the following properties from the Web Service Deployment Settings screen:
- Web service deployment environment selection: Use Default
- Web project: MATHServicesWeb
On the next screen we will configure the JavaBean as a Web service (see Figure 7). Use the default parameter from Websphere (configure the JavaBean as a Web service). The following parameter is:






