Undefined property: stdClass::$GetDataResult Error

2019-08-26 11:43发布

问题:

I'm Using PHP Soap Client function to connect Remote service using this code

try
{
    $result = $soapClient->GetData($parameters);
}
catch (SoapFault $fault)
{
    echo "Fault code: {$fault->faultcode}" . NEWLINE;
    echo "Fault string: {$fault->faultstring}" . NEWLINE;
    if ($soapClient != null)
    {
        $soapClient = null;
    }
    exit();
}
$soapClient = null;

Finally I'm calling this function,

echo "Return value: {$result->GetDataResult}" . NEWLINE;

But It's not working for me and got warning message like this.

Notice: Undefined property: stdClass::$GetDataResult

回答1:

You are ASSUMING that the response comes as an object with the property "GetDataResult". What makes you think so? This is not the case, and that's why you get this error message.

Dump the content of $result to see what you really get. You can also look at the WSDL file to see what the service promises to respond with.