Using PHPObject (Web Services)
Overview
With PHPObject, you can consume a web service in just three steps. While some knowledge of SOAP will be helpful, it is not necessary. If you know what operations are available, what parameters to pass, and the web service's wsdl location, you can consume the web service with PHPObject.
Installation (Web Services Connectivity Addon)
To consume web services with PHPObject, you need to the Web Services Connectivity Add-on. After downloading the zip file, extract the archive. Upload the nusoap.php and WebServiceProxy.php files to the server (same path as Gateway.php or the path you have specified for storing your php classes). The nusoap.php in this package was originally written by Dietrich Ayala and is v0.6.4 and has been modified here; specifically the getOperations method of the wsdl class has been modified.
Actionscripts
As mentioned, there are just three steps (not counting the #include and configuration lines):
// STEP 1: create a PHPObject and link it with a web service
mySvc = new PHPObject("http://services.xmethods.net/soap/urn:xmethods-delayed-quotes.wsdl");
// STEP 2: set up the responder
mySvc.onResult = function(result) {
trace(result)
}
// STEP 3: invoke the web service
mySvc.getQuote("symbol","IBM");
Examples
The following is a non-exhaustive list of the web services tested to work with PHPObject:
// AirportWeather
// wsdl location
mySvc = new PHPObject("http://live.capescience.com/wsdl/AirportWeather.wsdl");
// parameters (you can pass directly in the operation below)
arg0 = "KJFK"; // ICAO code for New York JFK airport
// operation
mySvc.getSummary("arg0",arg0);
/*
This web service is quite slow; recommended to use GlobalWeather web service below instead.
The following are ICAO designations for some popular airports:
KJFK - New York JFK
KLAX - Los Angeles Intl.
EIDW - Dublin, Ireland
VHHH - Hong Kong Intl.
EHAM - Amsterdam
EGLL - London Heathrow
YSSY - Sydney Intl.
RJTT - Tokyo Intl.
HECA - Cairo
Check out http://www.ar-group.com/icaoiata.htm for other codes.
*/
// BabelFish Translation
// wsdl location
mySvc = new PHPObject("http://www.xmethods.net/sd/2001/BabelFishService.wsdl");
// parameters (you can pass directly in the operation below)
transmode = "en_zh";
source = "string of text you want translated";
// operation
mySvc.BabelFish(
"translationmode",transmode,
"sourcedata",source
);
/*
Translation translationmode
----------- ----------------
English -> Chinese "en_zh"
English -> French "en_fr"
English -> German "en_de"
English -> Italian "en_it"
English -> Japanese "en_ja"
English -> Korean "en_ko"
English -> Portugese "en_pt"
English -> Spanish "en_es"
French -> English "fr_en"
Chinese -> English "zh_en"
German -> English "de_en"
Italian -> English "it_en"
Japanese -> English "ja_en"
Korean -> English "ko_en"
Portugese -> English "pt_en"
Russian -> English "ru_en"
Spanish -> English "es_en"
*/
// Barnes & Noble Book Price
// wsdl location
mySvc = new PHPObject("http://www.xmethods.net/sd/2001/BNQuoteService.wsdl");
// parameters (you can pass directly in the operation below)
isbn = "0618162216"; // isbn of the book
// operation
mySvc.getPrice(
"isbn",isbn
);
// Currency Exchange Rate
// wsdl location
mySvc = new PHPObject("http://www.xmethods.net/sd/2001/CurrencyExchangeService.wsdl");
// parameters (you can pass directly in the operation below)
country1 = "united states"; // 1 unit of this currency
country2 = "australia"; // converts to how many of this currency?
// operation
mySvc.getRate(
"country1",country1,
"country2",country2
);
// Check here for valid country names:
// http://xmethods.com/ve2/ViewListing.po;jse...45-3665D11A12E5
// Delayed Stock Quote (20 minute delayed stock quote)
// wsdl location
mySvc = new PHPObject("http://services.xmethods.net/soap/urn:xmethods-delayed-quotes.wsdl");
// parameters (you can pass directly in the operation below)
symbol = "IBM"; // stock ticker symbol
// operation
mySvc.getQuote(
"symbol",symbol
);
// Domain Name Checker
// wsdl location
mySvc = new PHPObject("http://services.xmethods.net/soap/urn:xmethods-DomainChecker.wsdl");
// parameters (you can pass directly in the operation below)
domainname = "domain.com"; // the domain name you want to check
// operation
mySvc.checkDomain(
"domainname", domainname
);
// returns 'available' or 'unavailable' for domain name registration
// GlobalWeather
// wsdl location
mySvc = new PHPObject("http://live.capescience.com/wsdl/GlobalWeather.wsdl");
// parameters (you can pass directly in the operation below)
stationcode = "AMS"; // 'AMSTERDAM', IATA/FAA code
// operation
mySvc.getWeatherReport(
"code",stationcode
);
/*
This returns an object, so make sure you traverse into the properties to get the results. For more info, please refer to
http://www.capescience.com/webservices/glo...her/index.shtml
Other operations available in this web service:
getStation()
isValidCode()
listCountries()
searchByCode()
searchByCountry()
searchByLocation()
searchByName()
searchByRegion()
*/
// Romulan Numbers XLII
// wsdl location
mySvc = new PHPObject("http://www.ebob42.com/cgi-bin/Romulan.exe/wsdl/IRoman");
// parameters (you can pass directly in the operation below)
Int = 42; // integer to convert a roman number
Rom = "XV"; // string to convert to digital number
// operation (converts digital number to roman number)
mySvc.IntToRoman(
"Int",Int
);
// operation (converts roman number to digital number)
mySvc.RomanToInt(
"Rom",Rom
);
// Site Inspector
// wsdl location
mySvc = new PHPObject("http://www.flash-db.com/services/ws/siteInspect.wsdl");
// parameters (you can pass directly in the operation below)
siteURL = "www.mydomain.com";
// operation
mySvc.doSiteInspect(
"username","Any",
"password","Any",
"siteURL", siteURL
);
/*
This service returns an object, so make sure you traverse into the properties to get the results.
*/
>> Documentation <<
|