|
|
|
|
@ -1,4 +1,8 @@
|
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
use App\Services\LogService;
|
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
|
|
|
|
|
|
class Yz{
|
|
|
|
|
public static function echo($data=[],$code=200){
|
|
|
|
|
$result=array();
|
|
|
|
|
@ -26,5 +30,87 @@ class Yz{
|
|
|
|
|
$result['data']=$data;
|
|
|
|
|
return $result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static function XmlHttp($SendData,$url){
|
|
|
|
|
|
|
|
|
|
// 记录请求开始时间
|
|
|
|
|
$start_time = microtime(true);
|
|
|
|
|
$xml_post_string = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:com="http://com.wondersgroup.jkda.application.modules.webservice">
|
|
|
|
|
<soapenv:Header/>
|
|
|
|
|
<soapenv:Body>'
|
|
|
|
|
.$SendData.
|
|
|
|
|
'</soapenv:Body>
|
|
|
|
|
</soapenv:Envelope>';
|
|
|
|
|
|
|
|
|
|
$headers = array(
|
|
|
|
|
"Content-type: text/xml;charset=utf-8",
|
|
|
|
|
"Accept: text/xml",
|
|
|
|
|
"Cache-Control: no-cache",
|
|
|
|
|
"Pragma: no-cache",
|
|
|
|
|
"Content-length: ".strlen($xml_post_string),
|
|
|
|
|
"appCode: glMzZT",
|
|
|
|
|
"sign: E98BB73DE7356B1641BCA0D025D7CD11",
|
|
|
|
|
"apiCode: 9051ecd6-dd16-4cdb-9a38-ca159114febd",
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$ch = curl_init();
|
|
|
|
|
curl_setopt($ch, CURLOPT_URL, $url);
|
|
|
|
|
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
|
|
|
|
curl_setopt($ch, CURLOPT_POST, 1);
|
|
|
|
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_post_string);
|
|
|
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
|
|
|
|
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 20);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$resdata = curl_exec($ch);
|
|
|
|
|
// 记录请求结束时间
|
|
|
|
|
$end_time = microtime(true);
|
|
|
|
|
// 计算时间差
|
|
|
|
|
$request_time = $end_time - $start_time;
|
|
|
|
|
|
|
|
|
|
// 打印请求时间
|
|
|
|
|
echo "请求时间:{$request_time} 秒";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$result="";
|
|
|
|
|
try {
|
|
|
|
|
if(curl_errno($ch)) {
|
|
|
|
|
$result=curl_error($ch);
|
|
|
|
|
// print curl_error($ch);
|
|
|
|
|
} else {
|
|
|
|
|
curl_close($ch);
|
|
|
|
|
|
|
|
|
|
$res = explode('<soap:Body>', $resdata)[1];
|
|
|
|
|
$res = explode('</soap:Body>', $res)[0];
|
|
|
|
|
|
|
|
|
|
$xmlObject = simplexml_load_string($res);
|
|
|
|
|
$jsonData = json_encode($xmlObject);
|
|
|
|
|
$result = json_decode($jsonData, true);
|
|
|
|
|
}
|
|
|
|
|
}catch (Exception $e) {
|
|
|
|
|
$result = $e->getMessage();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LogService::CheckTableName();
|
|
|
|
|
date_default_timezone_set('PRC');
|
|
|
|
|
$table_name='zz_request_log_' . date('ym');
|
|
|
|
|
$formatted_date= date("Y-m-d H:i:s");
|
|
|
|
|
DB::table($table_name)->insert([
|
|
|
|
|
'request_ip'=>'',
|
|
|
|
|
'response_data'=>json_encode($result, JSON_UNESCAPED_UNICODE),
|
|
|
|
|
'header_data'=>'',
|
|
|
|
|
'post_data'=>$SendData,
|
|
|
|
|
'get_data'=>'',
|
|
|
|
|
'request_url'=>$url,
|
|
|
|
|
'create_time' => $formatted_date,
|
|
|
|
|
'update_time' => $formatted_date
|
|
|
|
|
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
return $result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|