我想在我的Web服务中返回一个字符串数组
我试过了:
<?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; }
但它不起作用.这个的正确语法是什么?
在此先感谢您的帮助
解决方法
首先需要定义一个描述字符串数组的新类型,如下所示:
$server->wsdl->addComplexType( 'ArrayOfString','complexType','array','sequence','',array( 'itemName' => array( 'name' => 'itemName','type' => 'xsd:string','minOccurs' => '0','maxOccurs' => 'unbounded' ) ) );
然后你可以使用tns:ArrayOfString作为返回类型.