我有一个使用SoapClient访问API的PHP脚本.连接后,如果我只发出一个请求,它按预期工作,但当我尝试使用相同的SoapClient对象发出第二个请求时,我收到一个Bad Request错误.
我相信这个问题可能与我的服务器配置有关,因为相同的PHP代码在另一台具有较旧版本PHP的计算机上工作正常但在我的测试和生产服务器上已更新到PHP 5.6都遇到此错误.
码:
<?php
class ReportAPI
{
protected $reportDataObject = null;
public function __construct($url = 'URL', $username = 'username', $password = 'pass') {
$this->client = new SoapClient($url , array('login' => $username, 'password' => $password, 'keep_alive' => true));
}
public function getReportData($reportID) {
return $this->getDataObject($reportID)->data;
}
public function getReportCount($reportID) {
return $this->getDataObject($reportID)->result_count;
}
public function runReport($reportID) {
$newID = $this->client->runReport($reportID);
$counter = 0;
while($this->client->checkReportRun($newID) != 'complete'){
if($counter > 2) {
throw new Exception('Report Time Out');
}
sleep(5); …Run Code Online (Sandbox Code Playgroud)