|
Comments
Did you read today's front page stories & breaking news?
SYS-CON.TV
|
Web Services Develop Web Services Clients
Using Macromedia Flash MX 2004
By: Sonny Hastomo
Feb. 23, 2005 12:00 AM
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 Server-Side Scenario 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)
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 Enter the following properties from the Web Service Deployment Settings screen:
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 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:
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 Reader Feedback: Page 1 of 1
Latest Cloud Developer Stories
Subscribe to the World's Most Powerful Newsletters
Subscribe to Our Rss Feeds & Get Your SYS-CON News Live!
|
SYS-CON Featured Whitepapers
Most Read This Week
Breaking Cloud Computing News
|
|||||||||||||||||||||||||||||||||||||||||||||||||