在我的 PHP Web 应用程序中处理“HTTP 500 内部服务器错误”时遇到问题。
我的 Web 应用程序正在循环访问多个外部 Web 服务,如果其中任何一个超出错误,我的脚本将终止而不执行其他 URL。
以下是我正在尝试处理的代码片段,我们将不胜感激。
如果有人想要更多信息,请告诉我。
$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;
谢谢。