Returning An Array of Objects in PHP Web Service

北城余情 提交于 2019-11-30 20:18:42

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!