I am facing problem in handling "HTTP 500 Internal Server Error" in my PHP web application.
My web app is hitting multiple external web services in loop and if any one of them is getting above error, my script is terminated without executing other URLs.
Following is the code snippet I am trying to work on, any help will be appreciated.
Please let me know if anybody wants more information.
$arrURLs = array('https://example1.com/abc1', 'https://example1.com/pqr2', 'https://example2.com/abc1', 'https://example2.com/pqr2');
$arrResponse = array();
foreach( $arrURLs as $strURL ) {
$soap_options = array('soap_version' => SOAP_1_1,
'debug'=>1,
'trace'=>1,
'exceptions'=>TRUE,
'cache_wsdl'=>WSDL_CACHE_NONE,
'connection_timeout'=> 500,
'stream_context' => stream_context_create(array('ssl' => array('verify_peer'=> false,'verify_peer_name'=>false,) ) ) );
try{
$client = new SoapClient( $strURL . '?wsdl', $soap_options );
$client -> __setLocation( $strURL );
$response = $client->method1();
array_push( $arrResponse, $response );
} catch(\Exception $e) {
$strError = 'Exception while connecting to URL: ' . $strURL . 'Error Message: ' . $e->getMessage();
echo $strError;
}
}
// parse $arrResponse after getting from all web services;
Thanks.