自2014年以来,我拥有每天运行的PHP Web服务。平均而言,它每天发送5000条消息。由于我每个月有1到2个这样的错误,但最近10天每天的错误数量增加到10个,因此消息数量略有增加到5200,并且我至少有2年没有做任何更改。我公司和正在接收这些消息的公司中的同事检查了网络中的错误,找不到任何错误。 上个月,我的脚本发送了超过50000条消息,没有错误,但是现在它在1000条以下消息后停止。 我得到的错误是:
Fatal error: Uncaught SoapFault exception: [HTTP] Could not connect to host in C:\xampp\htdocs\NIAS\BeSimpleSoap-master\
src\BeSimple\SoapClient\SoapClient.php:146
Stack trace:
#0 C:\xampp\htdocs\NIAS\BeSimpleSoap-master\src\BeSimple\SoapClient\SoapClient.php(203): BeSimple\SoapClient\SoapClient-
>__doHttpRequest(Object(BeSimple\SoapClient\SoapRequest))
#1 C:\xampp\htdocs\NIAS\BeSimpleSoap-master\src\BeSimple\SoapClient\SoapClient.php(183): BeSimple\SoapClient\SoapClient-
>__doRequest2(Object(BeSimple\SoapClient\SoapRequest))
#2 [internal function]: BeSimple\SoapClient\SoapClient->__doRequest('<?xml version="...', 'https://cis.api...', 'http://
www.apis...', 1, 0)
#3 C:\xampp\htdocs\NIAS\HZZO-OKP-SOAP.php(475): SoapClient->__call('sendMessage', Array)
#4 C:\xampp\htdocs\NIAS\HZZO-OKP-SOAP.php(475): BeSimple\SoapClient\SoapClient->sendMessage(Array)
#5 C:\xampp\htdocs\NIAS\HZZO-OKP-SOAP.php(403): Send_SOAP_mssg('Po\xC5\xA1tovana/i,<b...', '09596640-cbe0-4...', 18, 2,
'1111111', 'HR', 'Obavijest o sta...', 'https://cis.api. in C:\xampp\htdocs\NIAS\BeSimpleSoap-master\src\BeSimple\So
apClient\SoapClient.php on line 146
部分脚本如下:
function __autoload($class_name) {
include "C:\\xampp\\htdocs\\NIAS\\BeSimpleSoap-master\\src\\" .$class_name . '.php';
}
ini_set('memory_limit', '-1');
ini_set('max_execution_time', 0);
//Code for accessing remote protected OIB list.
$handle = curl_init();
$options = array(
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_SSL_VERIFYPEER => FALSE,
CURLOPT_CAINFO => $FINA_APIS_cert,
CURLOPT_VERBOSE => TRUE,
CURLOPT_SSL_VERIFYHOST => FALSE,
CURLOPT_SSLCERTPASSWD => $cert_password ,
CURLOPT_SSLCERT => $cert_path,
CURLOPT_SSLKEY => $key_path,
CURLOPT_SSLVERSION => 4,
CURLOPT_URL => $OIB_URL
);
curl_setopt_array($handle, $options);
$OIB_File=(string)curl_exec($handle); //String of OIBs
if (curl_errno($handle)) {
echo 'Error: ' . curl_error($handle);
}
curl_close($handle);
$OIB_row = str_getcsv($OIB_File, "\n",","); //parse the rows
foreach($OIB_row as $Row){
$Row = str_getcsv($Row, ","); //parse the items in rows
$Country_code = $Row[0];
$OIB_array[$Row[1]] = TRUE;
}
// Open connection with MySQL Database
$link_mysql = mysqli_connect("localhost", "****", "****", "okp_php");
$rows_lines="";
$flag_split_saldo=1;
$input_file=scandir($full_path);//Scanning directory for files
foreach ($input_file as $input_name){
if($input_name=="." || $input_name==".." || $input_name=="OIB")
continue;
$lines = file($full_path . $input_name);
foreach($lines as $line){
$line_row = explode(':', $line);
$security_level=2;
if(substr($input_name,0,7)=="naknade"){
$OIB=$line_row[9];
if (!isset($OIB_array[$OIB]))//searching for OIB in OIB list
continue;
$title="Obavijest o obračunatoj naknadi koju isplaćuje HZZO";
if(empty($line_row[6])){
$IBAN_tmp=$line_row[7].$line_row[8].'172700';
$IBAN=IBAN_generator($IBAN_tmp);
}
else{
$IBAN=$line_row[6];
}
$compensation = number_format($line_row[2],2);
$TipPoruke=14;
$UUID=gen_uuid();
$security_level=2;
$rows_lines ="Poštovana/i,<br />na Vaš račun " . $IBAN . " upućen je iznos od " . $compensation ." kuna za \"" . $line_row[5] . "\" za " . $line_row[0] . ". mjesec " . $line_row[1] . ". godine.<br /><br />Srdačan pozdrav,<br />Vaš HZZO";
}
else{
continue;
}
Send_SOAP_mssg($rows_lines,$UUID,$TipPoruke,$security_level,$OIB,$Country_code,$title,$SERVICE_TEST,$SOAP_cert,$NAMESPACE_URI,$cert_password,$Attachment_file,$link_mysql);
$Attachment_file="";
}
//Code for parsing only one saldo Dopunskog file
if (substr($input_name,0,12)=="sal_web_pla_"){
copy_file($flag_split_saldo,$full_path,$input_name,$destination);
$flag_split_saldo=0;
}
else
{
$flag_split_saldo=1;
copy_file($flag_split_saldo,$full_path,$input_name,$destination);
}
}
//Close MySQL connection
mysqli_close($link_mysql);
function Send_SOAP_mssg($rows_lines,$UUID,$TipPoruke,$security_level,$OIB,$Country_code,$title,$SERVICE_TEST,$SOAP_cert,$NAMESPACE_URI,$cert_password,$Attachment_file,$link_mysql){
$date_time = date("c");
$encoded_msg=base64_encode($rows_lines);
$encodded = new SoapVar("<tns:KorisnickiPretinacPoruka xmlns:tns='http://apis-it.hr/umu/2013/types/kp'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xsi:schemaLocation='http://apis-it.hr/umu/2013/types/kp ../schema/KorisnickiPretinacSchema.xsd '>
<tns:Zaglavlje>
<tns:IdPosiljatelja>196</tns:IdPosiljatelja>
<tns:TipPoruke>$TipPoruke</tns:TipPoruke>
<tns:IdPoruke>$UUID</tns:IdPoruke>
<tns:DatumVrijemeSlanja>$date_time</tns:DatumVrijemeSlanja>
<tns:RazinaSigurnosti>$security_level</tns:RazinaSigurnosti>
</tns:Zaglavlje>
<tns:Poruka>
<tns:PinPrimatelja>$OIB</tns:PinPrimatelja>
<tns:OznakaDrzave>$Country_code</tns:OznakaDrzave>
<tns:Predmet>$title</tns:Predmet>
<tns:Sadrzaj>$encoded_msg</tns:Sadrzaj>
</tns:Poruka>
$Attachment_file
</tns:KorisnickiPretinacPoruka>", XSD_ANYXML);
$par_envelope=array( "GsbEnvelope" =>
array( "MessageHeader" =>
array("SenderId" => "24",
"ServiceId" => "123",
"MessageId" => $UUID,
"SenderTimeStamp" => $date_time),
"Content" => array("MimeType" =>"application/xml","Data" =>array("any"=>$encodded,"encoding"=>"EMBEDDED"))));
$par_WSDL=array("trace"=>TRUE,
"exceptions"=>TRUE,
'location'=>$SERVICE_TEST,
"local_cert" =>$SOAP_cert,
'uri'=>$NAMESPACE_URI,
"passphrase"=>$cert_password,
"connection_timeout" => 60);
$client = new BeSimple\SoapClient\SoapClient("GSBService.wsdl",$par_WSDL);
$result=$client->sendMessage($par_envelope);
//Default error code A000 == No error
$Error_CodeK="A000";
$Error_CodeM="A000";
if(!empty($result->Errors)){
$Error_CodeM=$result->Errors->Error->ErrorCode;
}
print_r("<p>Request :".htmlspecialchars($client->__getLastRequest()) ."</p>");
print_r("<p>Response:".htmlspecialchars($xml=$client->__getLastResponse())."</p>");
$doc = new DOMDocument();
$doc->loadXML( $xml );
$SOAPRequest = $doc->getElementsByTagName( "SifraGreske" );
if($SOAPRequest->length!=0 || $Error_CodeM[0]!="A"){
if($SOAPRequest->length!=0)
$Error_CodeK=$SOAPRequest->item(0)->nodeValue;
$GsbId=gen_uuid();
$ReceiverTimeStamp=date("c");
}
else
{
$SOAPRequest = $doc->getElementsByTagName( "GsbId" );
$GsbId = $SOAPRequest->item(0)->nodeValue;
$SOAPRequest = $doc->getElementsByTagName( "ReplyReceivingTimeStamp" );
$ReceiverTimeStamp=$SOAPRequest->item(0)->nodeValue;
}
//Inserting errors and logins into MySQL
error_handling_logging($UUID,$GsbId,$ReceiverTimeStamp,$OIB,$rows_lines,$Error_CodeK,$Error_CodeM,$date_time,$link_mysql);
}