hide side navigation
    5 most recent
    Web Services
    Library's
    Component's
    Applications
  Tree menu  Flex 2 Guestbook  Videobox  Simple mp3 player  Videoroom  Moving menu  Flash db board reader  Simple photo gallery  Simplecart and External Interface  Email in Flash II  Photo and Video gallery  New Store  Flash GuestBook V2  Flash-db Miniboard  ActionScript dictionary  Private chat with FlashCom  Flash Whois  An online store  Flash RSS reader  Net Tools - Whois in Flash  Flash Message Board  Flash GuestBook  Email in Flash  Sending Custom Ecards  Simple Live Counter with PHP
    Articles
The following example use's AMFPHP and nusoap to create an easy to use, plug and play, whois lookup for your flash application. Below is a brief overview, however this application is mainly for sample code. This example assumes that you have amfphp and nusoap set-up and working correctly. If you don't, check out some of the articles or visit us on the flash-db message boards. (Try doing a whois on www.microsoft.com and read through the results).


The following assumes that you have Flash Remoting up and running, either AMFPHP or other.

If your using AMFPHP and have not installed nusoap yet, you may want to read over - Consuming Web Services with Flash and AMFPHP. In short download the latest version of nusoap and place this in a folder called 'lib' inside the flashservices directory (flashservices/lib). And that's it! Your now ready to consume webservices in flash.

AMFPHP in combination with Nusoap was used in this example, but the same actionscript code and services should work with any remoting software package (coldfusion, .net, etc).

The above example use's the following web service:
The actual code is included in the download, however the most important part of the code is posted below. The following should be enough to get you started. The NetConnection debugger will make everything really easy, so make sure you've downloaded the macromedia remoting components.



Flash Whois Service

#include "NetServices.as"
#include "NetDebug.as"

// create result handler for results and error messages.
serviceResult = new Object();
serviceResult.onResult = function(result){
    
Output.text = result;
}
serviceResult.onStatus = function(status){
    
Output.text = status.description;
}

// sets up the gateway connection.
var serverConn     = NetServices.createGatewayConnection("<PathToYourGateway>/gateway.php");

// sets up the service.
var service = serverConn.getService("http://www.flash-db.com/services/ws/flashWhois.wsdl", serviceResult);

// sets the onPress event handler for the submit button, which calls the doWhois service.
submit_btn.onPress = function() {
    
    
Output.text = "loading whois information for "+Input.text;
    
    
// Set the params and call the service
    // username and password can be anything, domain name must be a valid domain name.
    
params = {
        
username:"anything",
        
password:"anything",
        
domain:Input.text
    
}    
    
    if (
Input.text != "" && params.domain != "") {
        
        
// calls the method.
        
service.doWhois(params);
        
    } else {
        
Output.text = "Please enter a domain name";    
    }
}

And that's it. Hopefully enough to play around with.

 Download the Source Files
- be sure to check the message board for help/support.


Note to advanced AMFPHP users: One of the best and easiest ways to combine the error handling of AMFPHP, Nusoap, and the flash NetConnection debugger is by adding the following to the nuSoapImpl function (located in app/Executive.php):

place this after the if/else statment containing $result = $soapclient->call

if ($err = $soapclient->getError()) {
    
trigger_error("error with nusoap, ".$err, E_USER_ERROR);
} else {
    return
$result;
}

// $err is an error string that nusoap sets when ever an error is encountered.

This will return any errors nusoap encounters to the NetConnection debugger. So for example if you enter an invalid wsdl file, or an invalid method name, you may get something similar to this back:

"Error: error with nusoap, operation xxxxx not present."

Only attempt to add this if you are familiar with AMFPHP.