0

I have a PHP file that gets its contents from a WSDL file. One of the methods returns a Person object. I cannot see the Person class and what methods it contains since it is generated by the SoapClient (right?) during the method call, so how can I get the data from the Person object?

My code looks as follows:

try {
    $client = @new SoapClient("http://localhost/index.php:8080/personinformation?wsdl",
            array('trace' => 1));
}catch(SoapException $ex) {
    echo $ex->getMessage();
}
$person = $client->getPerson(1);

And since var_dump prints the below information when running var_dump($person);:

object(stdClass)#4 (3) { ["personId"]=> int(1234) ["name"]=> string(5) "peter" ["comments"]=> string(9) "Some info"}

...then I thought I could retreive the name with the function:

echo $person->getName()

But PHP then gives me this error:

Fatal error: Call to undefined method stdClass::getName() 

What have I missed?

Rox
  • 2,397
  • 13
  • 45
  • 78

0 Answers0