Joined: 24 Oct 2005 |
Posts: 3 |
|
|
|
Posted: Sun Oct 23, 2005 7:40 am |
|
|
|
|
|
Hi,
I am evaluating the Nusphere IDE and tried to create an nusoap webservice. I then tried to generate an nusoap client with the IDE however I am receiving an error: Document Contains no data. Which is actually strange. Can you help me out please?
I basically need to generate xml output, which can then be requested by the client.
Thanks.
Here's the web service code;
[php]
<?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',
'',
array(
'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(),
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) {
if (is_string($a_stInput)) {
$l_oDBlink = @mysql_connect(
'localhost', 'abc', 'xyz');
$l_oDBresult = @mysql_db_query(
'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
WHERE slot.date = ("' . mysql_escape_string((string)$a_stInput) . '")');
// simple error checking
if (!$l_oDBresult) {
return new soap_fault('Server', '', 'Internal server error.');
}
// no data avaible for x city
if (!mysql_num_rows($l_oDBresult)) {
return new soap_fault('Server', '',
'Service contains data only for a few cities.');
}
mysql_close($l_oDBlink);
// return data
$scheduleitem = array();
for ( $counter = 0;
$list = mysql_fetch_object( $l_oDBresult);
$counter++ )
{
$itemname = $list -> name;
$start = $list -> start;
$end = $list -> end;
// 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);
?>
[/php]
|