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

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 40
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 30
This is the Title of the Book, eMatter Edition
Copyright © 2003 O’Reilly & Associates, Inc. All rights reserved.
Hello World
|
29
Example 1-7 implements a simple class named HelloWorld that contains one
method, sayHello( ), which returns a string. The class is named the same as the file.
The
methodTable array is used by AMFPHP to look up functions to invoke and to
provide a pseudoimplementation of ColdFusion’s CFCExplorer utility, which docu-
ments the class, methods, properties, arguments, return types, and so forth.
Switch back to the Flash movie and change the
myURL variable in Example 1-1 to
point to the AMFPHP gateway:
var myURL = "http://yourservername/com/oreilly/frdg/gateway.php";
This is the only change that has to be made to the Flash movie, and it is necessary
because the PHP implementation utilizes PHP pages to handle the functionality of
the gateway.
If you run the movie in the test environment, you should see the phrase “Hello
World from PHP” in the Output window. If you don’t see it, verify that you have
correctly installed the AMFPHP classes and verify your code.
Web service
For the web service example, we will create a web service using ColdFusion MX.
However, any web service containing a sayHello( ) method that returns a string
works just as well.
Creating a web service in ColdFusion MX is extremely simple; we simply pass the
URL to our CFC, adding ?wsdl to the query string, which tells ColdFusion to gener-
ate a web service from the component. We’ll use the CFC that we created in
Example 1-2, HelloWorld.cfc, saved in the directory specified earlier.
Example 1-7. PHP code for HelloWorld.php
<?php
/* File: {SERVICES_CLASS_PATH}/com/oreilly/frdg/HelloWorld.php
provides the HelloWorld class used in Chapter 1. */
class HelloWorld {
function HelloWorld ( ) {
$this->methodTable = array(
'sayHello' => array(
'description' => 'Says Hello from PHP',
'access' => 'remote',
'arguments' => array ('arg1')
)
);
}
function sayHello ( ) {
return 'Hello World from PHP';
}
}
?>
Seitenansicht 30
1 2 ... 26 27 28 29 30 31 32 33 34 35 36 ... 39 40

Kommentare zu diesen Handbüchern

Keine Kommentare