nusoap 可以返回字符串数组吗? [英] Can nusoap return array of string?
本文介绍了nusoap 可以返回字符串数组吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在我的网络服务中返回一个字符串数组
I would like to return an array of string in my web services
我试过了:
<?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 ?
在此先感谢您的帮助
推荐答案
您首先需要定义一个新类型来描述字符串数组,如下所示:
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'
)
)
);
然后你可以使用 tns:ArrayOfString
作为返回类型.
Then you can use tns:ArrayOfString
as the return type.
这篇关于nusoap 可以返回字符串数组吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文