Returning An Array of Objects in PHP Web Service Returning An Array of Objects in PHP Web Service php php

Returning An Array of Objects in PHP Web Service


I fixed this error. For anyone interested, this seems to be a bug in NuSOAP. You MUST register your returnType for the function as xsd:Array for it to correctly return the array, even though correct WSDL would constitute it as 'tns:ArrayOfArticleType'. I found this in some Drupal source code:

// Set return value for the service$return = array();if ($method['#return']) {  **// Don't let a struct be declared as return parameter, because nusoap will not  // Send back anything.**  $return['return'] = 'xsd:'. $method['#return'];  if ($method['#return'] == 'struct' || $method['#return'] == 'array') {    $return['return'] = 'xsd:Array';  }} 

Hope this helps someone else who struggled with the same problem.


Here is example both client and server for how to return an array with php web service.It is easy example to understand http://my-source-codes.blogspot.com/2011/10/php-web-service-return-array.html