nusoap可以返回字符串数组吗?
我想在
我尝试过的网络服务中返回一个字符串数组:
<?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;
}
但它不起作用。正确的语法是什么?
预先感谢您的任何帮助
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您首先需要定义一个新类型来描述字符串数组,如下所示:
然后您可以使用 tns:ArrayOfString 作为返回类型。
You first need to define a new type that describes an array of strings like so:
Then you can use
tns:ArrayOfString
as the return type.此站点描述了一种返回复杂数据类型并使用 C# 接收它的好方法: http://sanity-free .org/125/php_webservices_and_csharp_dotnet_soap_clients.html
This site describes a nice way to return complex datatypes and receive it with C#: http://sanity-free.org/125/php_webservices_and_csharp_dotnet_soap_clients.html
返回数组数组时,您可能需要与 Oliver 不同的配置。例如 phfunc2php 在 nusoapcode.class.php 文件 (https: //github.com/sylnsr/pgfunc2php/blob/master/nusoapcode.class.php)。它生成的代码如下所示:
然后函数只需要返回“tnsArrayOfArrays:
如果您想看到这个,上面提到的项目可以为您编译工作代码。
When returning array of arrays, you might need a different configuration from Oliver. For example phfunc2php uses this technique in the nusoapcode.class.php file (https://github.com/sylnsr/pgfunc2php/blob/master/nusoapcode.class.php). The code it generates looks like so:
and then the functions simply needs to return "tnsArrayOfArrays:
The project mentioned above can compile working code for you, should you want to see this.