注意使用 nusoap 将数组转换为字符串 [英] Notice Array to string conversion using nusoap
问题描述
我正在使用 nosoap 用 PHP 开发 Web 服务.这是我的文件 webservice.php
I'm developing a web service in PHP, using nosoap. this is my file, webservice.php
<?php
require_once "nusoap/nusoap.php";
$namespace = "urn:mywsdl";
$server = new soap_server();
$server->configureWSDL('myWS', $namespace);
$server->wsdl->schemaTargetNamespace = $namespace;
$server->wsdl->addComplexType('datosBasicos', 'complexType', 'struct', 'all', '', array(
'codigo' => array(
'name' => 'codigo',
'type' => 'xsd:string'
),
'nombre' => array(
'name' => 'nombre',
'type' => 'xsd:string'
)
));
$server->wsdl->addComplexType('arraydatosBasicos', 'complexType', 'array', '', 'SOAP-ENC:Array', array(), array(
array('ref' => 'SOAP-ENC:arrayType',
'wsdl:arrayType' => 'tns:datosBasicos[]')
), 'tns:datosBasicos'
);
$server->register('saludar', array('nombre' => 'xsd:string'), array('return' => 'tns:arraydatosBasicos'), $namespace);
function saludar($nombre) {
$array[] = array('codigo' => '123', 'nombre' => 'test');
$array[] = array('codigo' => '5745', 'nombre' => 'probando');
$datos[] = $array[1];
return $datos;
}
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);
?>
但是,当我使用 SOAPUI 部署 Web 服务时,出现此错误:
But, when I deploy the web service, with SOAPUI, I get this error:
<b>Notice</b>: Array to string conversion in <b>C:\xampp\htdocs\nusoap\nusoap\nusoap.php</b> on line <b>6132</b><br />
我做错了什么?
推荐答案
我遇到了类似的错误,我不得不在 nusoap.php 中注释一行:
I got a similar error, I had to comment a line in nusoap.php..something like:
//$this->debug("$k = $v<br>");
对我来说很好.
显然,它仅用于调试,所以不要担心功能,因为如果您注释该行,它应该是相同的.我认为当您创建复杂数据时(这意味着,在您的情况下是另一个数组中的数组)nusoap 无法打印它以进行调试.
Obviously, it is only for debug so don't worry about the functionality, because it should be the same if you comment the line. I think when you create complex data (that's mean, in your case an array inside another array) nusoap is not able to print it for debugging.
无论如何祝你好运.
这篇关于注意使用 nusoap 将数组转换为字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!