MACROMEDIA FLASH REMOTING MX-USING FLASH REMOTING FOR FLASH MX 2004 ACTIONSCRIPT 2.0 Spezifikationen Seite 28

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 40
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 27
This is the Title of the Book, eMatter Edition
Copyright © 2003 O’Reilly & Associates, Inc. All rights reserved.
26
|
Chapter 1: Introduction to Flash Remoting
Java using JRun 4 or other J2EE servers
For the Java example, we will implement our remote service as a simple Java class.
Using Java as a remote service requires that the Flash Remoting gateway be installed
on a Java application server such as Macromedia’s JRun 4 or IBM’s WebSphere. The
Java version will not work with ColdFusion MX or Microsoft .NET servers.
Create a new plain text file in any text editor, name it HelloWorld.java, and enter the
code shown in Example 1-4.
Compile the class into your web server’s classpath. This may vary from server to
server, but the server’s WEB-INF (or SERVER-INF in the case of JRun) directory is
usually included within the server’s classpath. For example, to compile it using JRun
4, you would use (from a command prompt):
c:\jrun4\servers\myservername\server-inf\classes\com\oreilly\frdg\>javac
HelloWorld.java
If you are using JRun 4 and created the SSAS example earlier, rename HelloWorld.asr
to SomethingElse.asr to ensure that the Java class is used instead.
Once the class has been successfully compiled, place it in the
classpath\com\oreilly\
frdg\ directory and switch to Flash and test your movie. You should see the output
from the sayHello( ) method of the HelloWorld Java class. If you get an error that the
service cannot be found, make sure that you have compiled the class into the server’s
classpath.
Microsoft .NET server
ASP.NET services can be written in several languages, including VB.NET and C#.
This Microsoft .NET service example is implemented as a .NET DLL written in C#.
Open Microsoft’s Visual Studio .NET (VS.NET) and create a new project. From the
Project Types window, select Visual C# Projects; then, from the Templates window,
select Class Library. Set the name of the project to HelloWorld, as shown in
Figure 1-6. Rename the class file that appears from Class1.cs to HelloWorld.cs. The
code will work even if you do not rename the class file, but renaming it makes it eas-
ier to organize the files.
Example 1-5 shows the server-side C# code to implement the example as a Win-
dows .NET service.
Example 1-4. Java code for HelloWorld.java
package com.oreilly.frdg;
public class HelloWorld {
public String sayHello ( ) {
return "Hello World from Java";
}
}
Seitenansicht 27
1 2 ... 23 24 25 26 27 28 29 30 31 32 33 ... 39 40

Kommentare zu diesen Handbüchern

Keine Kommentare