Comments
Richard Davies wrote: The UK has a good crop of technology pioneers in cloud computing - for example ElasticHosts, FlexiScale, Flexiant, OnApp - and also some strong government initiatives such as G-Cloud. We will have to see whether this kind of technical leadership converts into swift mass-market adoption or not.
Cloud Expo on Google News

SYS-CON.TV
Cloud Expo & Virtualization 2009 East
PLATINUM SPONSORS:
IBM
Smarter Business Solutions Through Dynamic Infrastructure
IBM
Smarter Insights: How the CIO Becomes a Hero Again
Microsoft
Windows Azure
GOLD SPONSORS:
Appsense
Why VDI?
CA
Maximizing the Business Value of Virtualization in Enterprise and Cloud Computing Environments
ExactTarget
Messaging in the Cloud - Email, SMS and Voice
Freedom OSS
Stairway to the Cloud
Sun
Sun's Incubation Platform: Helping Startups Serve the Enterprise
POWER PANELS:
Cloud Computing & Enterprise IT: Cost & Operational Benefits
How and Why is a Flexible IT Infrastructure the Key To the Future?
Click For 2008 West
Event Webcasts
Develop Web Services Clients
Using Macromedia Flash MX 2004

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
Add the logic function in MathOperationBean. Click at MathOperationBean class; then put the following code to that class:

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
Click Next. On the Web Service EJBConfiguration screen, configure the enterprise bean as a Web service, click Next (see Figure 6).

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:

- Web Service Uri = http://tempuri .org/com.math.service.MathOperation - ISD File = Web Content/ WEB-INF/isd/java/com/math/service/MathOperation.isd - WSDL Service document name = Web Content/ wsdl/com/math/service/MathOperationService.wsdl - WSDL binding document name = Web Content/ wsdl/com/math/service/MathOperationBinding.wsdl - WSDL EJB binding document name = Web Content/ wsdl/com/math/service/MathOperationEJB.wsdl - WSDL interface document name = Web Content/ wsdl/com/math/service/MathOperation.wsdl - WSDL schema folder name = Web Content/ wsdl


The Web service definition file will later create a Web Content folder in your MATHServicesWeb Project. Click next to proceed to the Web Service Deployment Setting.

Specify the methods to deploy at the Web Service JavaBean Methods screen. Edit the encoding style for each method, if required. At this screen you can configure which method/function you want to publish as Web services. For our purposes, we will publish all the JavaBean methods that we have created. For both input and output encoding, choose SOAP encoding.

Click Finish to create the Web Service Deployment Description/WSDL file. Now run the Server Application: expand Server Configurations, right-click WebSphere v5.0 Server Configuration, and choose Run on Server.

Client-Side Scenario
Creating a Flash MX Project as a WebSphere Web Service Client Interface

Create the Flash MX Project - here we named it MathClientPJX.

On the General tab of the New Document box, choose Flash Document to create a document file to work with the input/output interfaces.

Add a label component on the canvas to design the interface for the Flash MX document. Give it the instance name: lblAppNotified [you will use this later to display the invoked method ApplicationInfo(String arg)].

Figure 8 shows the result of creating the Flash MX document interface; you will need to create three buttons, three textinputs, and one label component, and you must define every component with the instance name shown in Figure 8. Then save the Flash document (for our purposes, name it MathClient) and add the file to existing Flash project.

Now you need to create the MathAction class file to add the math operation behavior:

  • Create new ActionScript file from File > New > ActionScript File.
  • Save the ActionScript file as MathAction.as (remember, you need to use the same name as the class definition).
  • Add the ActionScript File to Flash MX Project (see Figure 9).
  • Enter the code shown in Listing 1 (Listings 1-4 can be downloaded from www.sys-con/websphere/sourcec.cfm).
  • Open the action toolbar, click Frame 1, and enter the code shown in Listing 2.
  • Click the Object button btnMultiply and enter the code shown in Listing 3.

    btnMultiply will invoke the MathObject wrapper and call the Multiply method from Web service.

  • Repeat this step for button btn- Add and btnSubtract, and enter the code shown in Listing 4.
Publishing WebSphere Web Services and Testing Flash MX Client Interactions with Web Services
Run Websphere v5.0 Test Environment. Click on menu File > Publish Preview > Flash to publish the Flash MX Application (see Figure 10). (For more information, visit www.macromedia.com.)

Summary
In this article, we built a Flash MX client for a simple math operation Web service that accepts two integer parameters and calculates the parameter to pass the result to the client. We also examined how to use an existing Web service, running on the application server provided within the WSDK, from within Macromedia Flash MX 2004 Professional. We then developed and tested a Flash MX 2004 client invoking the Web service and displaying the results in the Flash GUI application.

About Sonny Hastomo
Sonny Hastomo is an IT architect at Sun Microsystems, Indonesia, for the telecommunication industry division. His currently is focusing on providing solution design, sizing, implementation, consulting services, and quality support to customers in their evaluation of their IT challenges.

In order to post a comment you need to be registered and logged in.

Register | Sign-in

Reader Feedback: Page 1 of 1

Latest Cloud Developer Stories
Can you bring services from the cloud to your customers faster and have them adopt it with ease of use or bring the power of bundled services to the fingertips of your clients without creating new rigid ‘apps stove pipes'? Do you want to prevent your business running away to publ...
OCZ Technology Group, a provider of high-performance solid-state drives (SSDs) for computing devices and systems, on Tuesday announced the Z-Drive R4 CloudServ PCI Express (PCIe) flash storage solution, designed to accelerate cloud computing applications and reduce operating expe...
Many organizations have embraced, or are considering, the benefits of cloud computing – speed, flexibility, increased expertise, shared workload, reduced costs, etc. The benefits are many – but so are the risks. What are the threats to cloud security? Which parties assume respons...
In August 2011, SHI Enterprise Solutions (ESS) division launched the SHI Cloud, offering reliable and cost-effective industrial-grade cloud computing platforms. That same division achieved an 82 percent increase in revenue over 2010.
SoftLayer Technologies on Tuesday announced the immediate worldwide availability of SoftLayer Object Storage, a redundant and highly scalable cloud storage service that allows users to easily store, search and retrieve data across the Internet, with optional CDN connectivity, or ...
Subscribe to the World's Most Powerful Newsletters
Subscribe to Our Rss Feeds & Get Your SYS-CON News Live!
Click to Add our RSS Feeds to the Service of Your Choice:
Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
Publish Your Article! Please send it to editorial(at)sys-con.com!

Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021

SYS-CON Featured Whitepapers
ADS BY GOOGLE

Breaking Cloud Computing News
A new collaboration between a telecommunications infrastructure firm and a data center services prov...