Hi All,
I am tearing my hair out trying to get my head around nuSoap and activating the WSDL parts. I seem to be tripping up in developing the Complex Types to define how my data is being sent. All the tutorials seem to only use simple arrays with one record set. I suspect it's quite simple to tweak for multiple results - such as Db queries which returns multiple rows - but for some reason I am having difficulty making that logic leap. The following is a test Server:
require_once ('nusoap.php');
$server = new soap_server();
$server->register('getBook');
function getBook($inputParameters) {
// A database query takes the input parameters whcih is a list of Book ID Numbers, and returns the results.
// Sample $inputParameters
//$inputParameters = array('4567,9877,1546,7789,3374');
//TDummy results from database to use as test data
$title1 = 'Book Title 1';
$price1 = '15.95';
$ship1 = '2.98';
$title2 = 'Book Title 2';
$price2 = '22.49';
$ship2 = '3.97';
//Buidl the Output array
$retval = array(array(Title => $title1,
Price => $price1,
Shipping => $ship1
),
array(Title => $title2,
Price => $price2,
Shipping => $shipping2
)
);
return $retval;
}
// Use the request to (try to) invoke the service
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);
|
Can someone please help me with writing the $server->wsdl->addComplexType tag that explains the array being sent back. From the samples I think it needs to look something like this:
$server->wsdl->addComplexType(
'bookDetails',
'complexType',
'struct',
'all',
'',
array(
'title' => array('name' => 'title', 'type' => 'xsd:string'),
'price' => array('name' => 'price', 'type' => 'xsd:string')
)
);
|
But I can't seem to get it working. All the samples seem to be written for a normal array - and I'm having trouble tweaking them for a multidimensional one.
Thanks in advance for your help