NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
nuSoap


Joined: 24 Oct 2005
Posts: 3
Reply with quote
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]
View user's profileFind all posts by BsalibaSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 7887
Reply with quote
how did you access this service? Probably you forgot to add ?wsdl in the URL.
Look at this post on how to work with nusoap:
nusoap-sample-s-t55.html
View user's profileFind all posts by dmitriSend private messageVisit poster's website
nusoap


Joined: 24 Oct 2005
Posts: 3
Reply with quote
Thanks for your quick reply.

I have the service setup on a different machine with apache. Basically what i did was typed the url in the nusoap client wizard in the ide - http://myserver/nusoap/scheduleservice.php?wsdl

I was then prompted for the date, which I filled in with a date which I know will return data. It should actually return 2 rows in the array. I will have a look at the link you provided in the meantime too.
View user's profileFind all posts by BsalibaSend private message
nusoap


Joined: 24 Oct 2005
Posts: 3
Reply with quote
I had a look at the link. I'm afraid, its not the same error msg. Could it be because I am trying to return an array?
View user's profileFind all posts by BsalibaSend private message
nuSoap
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic