Index.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. namespace app\controller;
  3. use app\BaseController;
  4. use app\common\array2xml;
  5. use think\facade\Db;
  6. use think\facade\Cache;
  7. class Index extends BaseController
  8. {
  9. public function index()
  10. {
  11. phpinfo();
  12. }
  13. public function hello($name = 'ThinkPHP6')
  14. {
  15. return 'hello,' . $name;
  16. }
  17. public function getReport()
  18. {
  19. use_soap_error_handler(false);
  20. $client = new \SoapClient('http://localhost:8085/server.php?wsdl'); //请求的ip localhost:8085为本机测试
  21. $data = [
  22. 'Barcode'=>'122030200248721'
  23. ]; //请求参数
  24. $a2x = new array2xml();
  25. $data = $a2x->toXml($data); //参数转xml
  26. try{
  27. $result = $client->getDiAnData($data); //请求获取接口
  28. }catch(\SoapFault $e){
  29. return $e->getMessage();
  30. }
  31. var_dump(htmlspecialchars($result));die;
  32. $obj = simplexml_load_string($result,"SimpleXMLElement", LIBXML_NOCDATA);
  33. $ins = json_encode($obj);
  34. $obj = json_decode($ins,true);
  35. var_dump($obj);die;
  36. }
  37. public function aa()
  38. {
  39. $conn = mysqli_connect('localhost','root','');
  40. $a = mysqli_select_db($conn,'tijianzhongxin');
  41. $sql = "select * from dianApiInfo where Barcode='12203020024872'";
  42. $result = mysqli_query($conn, $sql);
  43. $info = mysqli_fetch_row($result);
  44. if(!empty($info))
  45. {
  46. $return = [
  47. 'xml'=>$info[1],
  48. 'patientId'=>$info[2],
  49. 'barCode'=>$info[3]
  50. ];
  51. $a2x = new array2xml();
  52. $r = $a2x->toXml($return);
  53. return $r;
  54. }else{
  55. return '';
  56. }
  57. }
  58. }