PHP Soap方法调用不会返回所有数据,但是__getLastResponse会返回

时间:2019-03-13 10:17:08

标签: php soap php-7.1

我正在使用php soap调用方法。

$options = ['trace' => 1,
            'exceptions' => true,
            'wsdl_cache' => WSDL_CACHE_NONE];

$wsdl = 'confidential-wsdl';
$client = new \SoapClient($wsdl,$options);

try {
    $result = $client->__call("SomeClientsMethod",array($params));
    $response = $client->__getLastResponse();
    var_dump($result); // Not all data received
    var_dump($response); // All data received
} catch (\Exception $e) {
    //No exception thrown
    throw new \Exception("Request failed!".$client->__getLastResponse());
}

此调用不会返回wsdl中定义的所有数据, 但是,如果我调用$ client-> __ getLastResponse(),那么我可以正确接收所有数据

有人可以让我朝正确的方向调试吗? 预先感谢

调用方法和wsdl已用我未收到的其他数据更新。

2 个答案:

答案 0 :(得分:0)

要捕获错误,请尝试将通话包装在try/catch中:

try{
    $client = new \SoapClient($wsdl,$options);
    $client->__call("SomeClientsMethod",array($params));
}

# I'm not sure exactly which one of these it is:

catch(Throwable $e){
    var_dump($e->getMessage());
}
catch (SoapFault $e) {
    var_dump($e->getMessage());
}

答案 1 :(得分:0)

这似乎是一个缓存问题。 可能是因为php.ini中的soap.wsdl_cache_ttl = 86400选项 现在,调用函数将返回所有数据...

感谢答案