private function soap_request($guid, $type) { for ($i = 1; $i <= 2; $i++) { try { $client = new \SoapClient("http://www.eu-nomen.eu/portal/soap.php?wsdl=1", array("trace" => false)); try { if ($type == 1) { return $client->getPESIRecordByGUID($guid); } elseif ($type == 2) { return $client->getPESISynonymsByGUID($guid); } elseif ($type == 3) { return $client->getPESIVernacularsByGUID($guid); } } catch (\SoapFault $sp) { echo "\n error in soap call \n"; } } catch (\Exception $e) { echo "\n error in creating soap client \n"; } echo "\n\n retrying after a minute... attempt {$i} [{$guid}][type: {$type}]"; sleep(60); } echo "\n investigate " . $i - 1 . " attempts failed [{$guid}][{$type}]\n"; return false; }