12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- <?php
- function SoapToXml($xml)
- {
- //api测试先关闭
- $startStr=strrpos($xml,"<![CDATA[");
- $endStr=strpos($xml,"]]>");
- $xml=substr($xml,$startStr,$endStr-$startStr);
- $xml = str_replace("<![CDATA[>","",$xml);
- $xml = str_replace("<![CDATA[","",$xml);
- $xml = str_replace("]]]]>","",$xml);
- $xml = str_replace("]]>","",$xml);
- $xml = str_replace("<ILLEGAL VALUE>","",$xml);
- return $xml;
- }
- //==============获得前台请求==============
- $callback = isset($_GET['callback']) ? trim($_GET['callback']) : '';
- $req['HospitalId'] = $_GET['hospitalId'];
- $req['startDate'] = $_GET['startDate'];
- $req['endDate'] = $_GET['endDate'];
- $req['deptId'] = $_GET['deptId'];
- if(isset($_GET['doctorId'])) {
- $req['doctorId'] = $_GET['doctorId'];
- }
- //$req = simplexml_load_string($req); //提取POST数据为simplexml对象
- $TradeCode = "1004";
- $ExtOrgCode = "南方医务通";
- $ExtUserID = "NFYWT";
- $ClientType ="";
- $HospitalId =$req['HospitalId'];
- $DeptType = "";
- $DoctorCode = "";
- $SessType = "";
- $StartDate = $req['startDate'];
- $EndDate = $req['endDate'];
- $RBASSessionCode = "";
- $ServiceCode = "";
- $StopScheduleFlag = "";
- $DepartmentCode = $req['deptId'];
- $DoctorCode= empty($req['doctorId'])?'':$req['doctorId'];
- $SearchCode = "";
- ini_set('user_agent', 'Mozilla/5.0');
- $postData = "<Request><HospitalId>$HospitalId</HospitalId><ExtOrgCode>$ExtOrgCode</ExtOrgCode><ExtUserID>$ExtUserID</ExtUserID><ClientType>$ClientType</ClientType><TradeCode>$TradeCode</TradeCode><DeptType>$DeptType</DeptType><DoctorCode>$DoctorCode</DoctorCode><SessType>$SessType</SessType><StartDate>$StartDate</StartDate><EndDate>$EndDate</EndDate><RBASSessionCode>$RBASSessionCode</RBASSessionCode><ServiceCode>$ServiceCode</ServiceCode><StopScheduleFlag>$StopScheduleFlag</StopScheduleFlag><DepartmentCode>$DepartmentCode</DepartmentCode><SearchCode>$SearchCode</SearchCode></Request>";
- //$postData = str_replace(' ','%20',$postData);
- //$wsdl = "http://yygh1.dept.nfyy.com/csp/oep/DHC.OEP.BS.OEPSTANWebService.cls?soap_method=QuerySchedule&Input=";
- //$result = file_get_contents($wsdl.$postData);
- $url = "http://yygh1.dept.nfyy.com/csp/oep/DHC.OEP.BS.OEPSTANWebService.cls?soap_method=QuerySchedule&Input=";
- $url .= $postData;
- ini_set('memory_limit', '256M');
- set_time_limit(0);
- $curl = curl_init();
- curl_setopt_array($curl, array(
- CURLOPT_URL => $url,
- CURLOPT_RETURNTRANSFER => true,
- CURLOPT_ENCODING => "",
- CURLOPT_MAXREDIRS => 10,
- CURLOPT_TIMEOUT => 30,
- CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
- CURLOPT_CUSTOMREQUEST => "GET",
- CURLOPT_HTTPHEADER => array(
- "cache-control: no-cache"
- ),
- //CURLOPT_USERAGENT => "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727;http://www.baidu.com)",
- ));
- $result = curl_exec($curl);
- $error = curl_error($curl);
- curl_close($curl);
- $res = SoapToXml($result);
- $res = simplexml_load_string($res);
- echo $callback.'('.json_encode($res).')';exit;
|