NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
addComplexType for Associative Array


Joined: 19 Jun 2008
Posts: 1
Reply with quote
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:


Code:

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:

Code:

$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 Smile
View user's profileFind all posts by Andy2785Send private message
addComplexType for Associative Array
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