Calling Enterprise Javabeans (Ejbs) From Flash; Getting A Reference To An Ejbhome Object In Actionscript; Invoking Ejb Methods In Actionscript - MACROMEDIA FLASH REMOTING MX-USING FLASH REMOTING FOR FLASH MX 2004 ACTIONSCRIPT 2.0 Use Manual

Using flash remoting for flash mx 2004 actionscript 2.0
Table of Contents

Advertisement

Calling Enterprise JavaBeans (EJBs) from Flash

The following sections describe how to get a reference to an EJBHome object and call Enterprise
JavaBeans (EJB) methods from ActionScript.

Getting a reference to an EJBHome object in ActionScript

Before calling the methods of an EJB from ActionScript, you must get a reference to an
EJBHome object.
To get a reference to an EJBHome object:
Import the mx.remoting.Service file:
1.
import mx.remoting.Service;
Connect to the Flash Remoting gateway and get a reference to the EJBHome object:
2.
SampleLoanHome = new Service(
"http://localhost/flashservices/gateway",
null,
"SampleLoan",
null,
null);
The first parameter of the Service object is the gateway URL. The third parameter is the Java
Naming and Directory Interface (JNDI) name of the EJBHome object. The JNDI name
cannot contain a period (.).
Note: There are several other ways to specify the gateway URL. For more information, see
Chapter 2, "Configuring Flash Remoting," on page

Invoking EJB methods in ActionScript

Unlike JavaBeans and Java classes, you must invoke the
and return an EJBObject object before calling EJBObject methods. After you call the
method of an EJBHome object, you can use the ActionScript
create_Result(re:ResultEvent)
invoke its methods.
For example, the following method of a stateless session bean performs loan calculations based on
loan principal, term, and interest rate:
public double calculate(double principal, int months, float rate){
if (rate < 0 || rate>1) return 0.0;
double monthlyPayment = principal * (rate / (1 - Math.pow(1 +
rate,-months)));
return monthlyPayment;
}
To invoke the preceding method, you could use the following ActionScript code:
import mx.remoting.Service;
import mx.remoting.PendingCall;
import mx.rpc.RelayResponder;
import mx.rpc.FaultEvent;
import mx.rpc.ResultEvent;
128
Chapter 7: Using Flash Remoting for Java
36.
create()
function to get a reference to the EJBObject object and
method of an EJBHome object
create()

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH REMOTING MX-USING FLASH REMOTING FOR FLASH MX 2004 ACTIONSCRIPT 2.0 and is the answer not in the manual?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flash remoting mx

Table of Contents