Hi Everyone,

I am programming a SOAP API using WSDL. I have managed to create some of the basic functionality and things have been working well up to this point!

Here's my Server object

<?php
ini_set("soap.wsdl_cache_enabled", "0");
$server = new SoapServer("wsdl.wsdl"); 
$server->setClass("api");
$server->handle();
exit();
?>

My basic functions are working fine when i return single variables or an array. However, i am now trying to return a multidemnsional array that has been turned into an object and the API returns nothing.

		$result = self::arr2obj(
			array("Result" => 
				array(
					array("Fruits" => array("Banana" => "yellow", "Apple" => "Green")), 
					array("Vegs" => array("Carrots" => "Orange", "Peas" => "Yellow"))
				)
			)
		);

	return $result;

Returns nothing. Although i know my arr2obj function is definately compiling an object out of the array as i have tried logging it to file.

if i change my function to just return something like this:

return array("apple" => "green", "banana" => "yellow")

it returns the array as expected.

The documentation on php soap is very limited and I have tried so many variations i don't knowwhere else to look.

Thanks for any help!

    If you do a [man]var_dump/man on the return value, what do you get? (I'm not familiar with the SOAP stuff, but I figure this might at least give you a hint if it's returning a boolean false or some other "interesting" value that could point you in the right direction.)

      yeah i did that.

      I used print_r to log the object to a file so i could check that there wasnt another problem. It is correctly creating the object. It's something to do with the Soap server not encoding it. Maybe its a WSDL thing but this is all quite new to me!

      Cheers

        here is the output of var_dump

        stdClass::set_state(array(
        'Result' =>
        stdClass::
        set_state(array(
        '0' =>
        stdClass::set_state(array(
        'Fruits' =>
        stdClass::
        set_state(array(
        'Banana' => 'yellow',
        'Apple' => 'Green',
        )),
        )),
        '1' =>
        stdClass::set_state(array(
        'Vegs' =>
        stdClass::
        set_state(array(
        'Carrots' => 'Orange',
        'Peas' => 'Yellow',
        )),
        )),
        )),
        ))

          Write a Reply...