|
nuSoap
I am quite a newbie in php but am trying to create a web service that returns multiple arrays of data. However, I got stuck on the client side. Basically, i'd simply like to manage to create a client php script with nusoap which can extract and display the returned array. Below is the server side code. Any guru out there who can help me out please?
Thanks
php Code:
Original
- php Code |
|
|
|
<?php // includes nusoap classes require('nusoap.php'); // create server $l_oServer = new soap_server(); // wsdl generation $l_oServer->debug_flag=false; $l_oServer->configureWSDL('TvData', 'http://fakeabctv.org/schedule'); $l_oServer->wsdl->schemaTargetNamespace = 'http://fakeabctv.org/schedule'; // add complex type $l_oServer->wsdl->addComplexType( 'scheduleitem', 'complexType', 'struct', 'all', '', 'name' => array('name'=> 'name', 'type'=> 'xsd:string'), 'start' => array('name'=> 'start', 'type'=> 'xsd:string'), 'end' => array('name'=> 'end', 'type'=> 'xsd:string')) ); $l_oServer->wsdl->addComplexType( 'dailyschedule', 'complexType', 'array', '', 'SOAP-ENC:Array', array('ref'=> 'SOAP-ENC:arrayType', 'wsdl:arrayType'=> 'tns:scheduleitem[]') ), 'tns:scheduleitem' ); // register method $l_oServer-> register('getSchedule', array( 'date' => 'xsd:string'), array('return'=> 'tns:dailyschedule'), 'http://fakeabctv.org/schedule'); // method code (get DB result) function getSchedule ($a_stInput) { 'localhost', 'root', 'root'); 'tvdb', 'SELECT item.name, slot.start, slot.end FROM (episode INNER JOIN item ON episode.itemID = item.itemID) INNER JOIN slot ON episode.episodeID = slot.episodeID // simple error checking if (!$l_oDBresult) { return new soap_fault('Server', '', 'Internal server error.'); } // no data avaible for x city return new soap_fault('Server', '', 'Service contains data only for a few cities.'); } // return data for ( $counter = 0; $counter++ ) { $itemname = $list -> name; $start = $list -> start; // build table to display results $scheduleitem[] = array('name' => $itemname, 'start' => $start, 'end' => $end); } $schedule = array('scheduleitem' => $scheduleitem); return $schedule; } // we accept only a string else { return new soap_fault('Client', '', 'Service requires a string parameter.'); } } // pass incoming (posted) data $l_oServer->service($HTTP_RAW_POST_DATA); ?>
|