nusoap可以返回字符串数组吗?

发布于 2024-08-28 11:54:59 字数 569 浏览 11 评论 0原文

我想在

我尝试过的网络服务中返回一个字符串数组:

<?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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

内心荒芜 2024-09-04 11:54:59

您首先需要定义一个新类型来描述字符串数组,如下所示:

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

然后您可以使用 tns:ArrayOfString 作为返回类型。

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.

一紙繁鸢 2024-09-04 11:54:59

此站点描述了一种返回复杂数据类型并使用 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

春庭雪 2024-09-04 11:54:59

返回数组数组时,您可能需要与 Oliver 不同的配置。例如 phfunc2php 在 nusoapcode.class.php 文件 (https: //github.com/sylnsr/pgfunc2php/blob/master/nusoapcode.class.php)。它生成的代码如下所示:

$server->wsdl->addComplexType(
    'ArrayOfArrays','complexType','array','',
    'SOAP-ENC:Array',
    array(),
    array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'xsd:string[]')));

然后函数只需要返回“tnsArrayOfArrays:

$server->register(
    'sel_signon_id_by_uuid',
    array('user_uuid' => 'xsd:string'),
    array('return'=>'tns:ArrayOfArrays'),

如果您想看到这个,上面提到的项目可以为您编译工作代码。

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:

$server->wsdl->addComplexType(
    'ArrayOfArrays','complexType','array','',
    'SOAP-ENC:Array',
    array(),
    array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'xsd:string[]')));

and then the functions simply needs to return "tnsArrayOfArrays:

$server->register(
    'sel_signon_id_by_uuid',
    array('user_uuid' => 'xsd:string'),
    array('return'=>'tns:ArrayOfArrays'),

The project mentioned above can compile working code for you, should you want to see this.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文