PHP SoapClient() gives error 500 and cannot catch the error

Went to an error 500 in production server while using PHP SoapClient library to connect to some third-party API. The error was really strange, just error 500 and nothing more, even if you are using try catch, you won’t be able to catch and see the error.

The Example:


try{
    $client = new SoapClient("https://api.thirdparty.com/some/service?wsdl", ['exceptions' => true, 'trace' => true]);
} catch(SoapFault $fault) {
    trigger_error("SOAP Fault: (faultcode: " . $fault->faultcode . ", faultstring: " . $fault->faultstring . ")", E_USER_ERROR);
} catch(Exception $e) {
    trigger_error("SOAP Error: " . $e->getMessage(), E_USER_ERROR);
}

Continue reading “PHP SoapClient() gives error 500 and cannot catch the error”