Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can nusoap return array of string?

I would like to return an array of string in my web services

I've tryed :

<?php
require_once('nusoap/nusoap.php');

$server = new soap_server();
$server->configureWSDL('NewsService', 'urn:NewsService');
$server->register('GetAllNews', 
 array(),
 array('return' => 'xsd:string[]'),
 'urn:NewsService',
 'urn:NewsService#GetAllNews',
 'rpc',
 'literal',
 ''
);

// Define the method as a PHP function
function GetAllNews()
{
 $stack = array("orange", "banana");
 array_push($stack, "apple", "raspberry");
 return $stack;
}

but it doesn't work. What is the correct syntax for that ?

Thanks in advance for any help

like image 275
Tim Avatar asked Apr 13 '10 11:04

Tim


1 Answers

You first need to define a new type that describes an array of strings like so:

$server->wsdl->addComplexType(
  'ArrayOfString',
  'complexType',
  'array',
  'sequence',
  '',
  array(
    'itemName' => array(
      'name' => 'itemName', 
      'type' => 'xsd:string',
      'minOccurs' => '0', 
      'maxOccurs' => 'unbounded'
    )
  )
);

Then you can use tns:ArrayOfString as the return type.

like image 88
Oliver Salzburg Avatar answered Oct 10 '22 20:10

Oliver Salzburg