4

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);
?>

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 />

What am I doing wrong?

4 Answers 4

7

I got a similar error, I had to comment a line in nusoap.php..something like:

//$this->debug("$k = $v<br>");

and it was fine for me.

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.

Anyway good luck.

Sign up to request clarification or add additional context in comments.

2 Comments

in newer nusoap version it is: $this->debug("serializing array element: $k, $v of type: $typeDef[arrayType]"); in line 6132
Thanks @user3980820 your solution solved! i was digging this from past several days!! :'-D
3

I have the same problem. You can convert the data to string to keep the debug for further usage and remove the warning

Search for this code

foreach(curl_getinfo($this->ch) as $k => $v){
    $err .= "$k: $v<br>";
}
$this->debug($err);

And replace with this one

foreach(curl_getinfo($this->ch) as $k => $v){
    if(is_array($v)){
        $v = implode(" / ", $v);
    }
    $err .= "$k: $v<br>";
}
$this->debug($err);

Comments

1

For latest nuSoap version, the below will solve your problem :

FIND the below code in nusoap.php

$this->debug("serializing array element: $k, $v of type: $typeDef[arrayType]"); 

in line 6132 or something around this no.

AND COMMENT IT

// $this->debug("serializing array element: $k, $v of type: $typeDef[arrayType]");

Since it just for debug purpose. so not to worry about any functionality issues.

Comments

0

I faced the same problem in nusoap-0.9.5 (for php5.3) and the error was occurring due to some server header being passed as blank array. So, I have added the following code and found it's working fine now.

if(is_array($v))
{
    $v = implode(",", $v );
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.