<?php
/************************************************** ************
* Simple SOAP server to return past Super Bowl results.
************************************************** ************/
// includes nusoap classes
require('../nusoap/lib/nusoap.php');
// create server
$l_oServer = new soap_server();
// wsdl generation
$l_oServer->debug_flag=false;
$l_oServer->configureWSDL('SuperBowlResults', 'http://chrismangano.x10hosting.com/SuperBowlResults');
$l_oServer->wsdl->schemaTargetNamespace = 'http://chrismangano.x10hosting.com/SuperBowlResults';
// add complex type
$l_oServer->wsdl->addComplexType(
'SuperBowlResults',
'complexType',
'struct',
'all',
'',
array(
'numeral' => array('name'=>'numeral', 'type'=>'xsd:string'),
'date' => array('name'=>'date', 'type'=>'xsd:string'),
'location' => array('name'=>'location', 'type'=>'xsd:string'),
'result' => array('name'=>'result', 'type'=>'xsd:string'))
);
// register method
$l_oServer->register('getResults', array(
'year' => 'xsd:int'),
array('return'=>'tns:SuperBowlResults'),
'http://chrismangano.x10hosting.com/SuperBowlResults');
// method code to get super bowl results based on year
function getResults ($a_stInput) {
if (is_integer($a_stInput)) {
// includes database class
require("../includes/config.inc.php");
require('../classes/Database.class.php');
// connect to the database
$db = new Database(DB_SERVER, DB_USER, DB_PASS, DB_DATABASE);
$db->connect();
$rows = $db->query("SELECT * FROM superbowl_results WHERE year =".$a_stInput);
echo $rows;
// check to make sure we have a result
if(!$rows){
return new soap_fault('Server', '', 'The table only has results since 2000.');
}
$db->close;
return $rows;
} else {
return new soap_fault('Client', '', 'Service requires a valid year.');
}
}
// pass incoming (posted) data
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$l_oServer->service($HTTP_RAW_POST_DATA);
?>