Index.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. libxml_disable_entity_loader(false);
  20. $opts = array(
  21. 'ssl' => array(
  22. 'verify_peer' => false
  23. ),
  24. 'https' => array(
  25. 'curl_verify_ssl_peer' => false,
  26. 'curl_verify_ssl_host' => false
  27. )
  28. );
  29. $streamContext = stream_context_create($opts);
  30. $client = new \SoapClient("http://112.103.134.89:10020/server.php?wsdl",
  31. array(
  32. 'stream_context' => $streamContext
  33. ));
  34. $data = [
  35. 'Barcode'=>'12203310010001'
  36. ]; //请求参数
  37. $a2x = new array2xml();
  38. $data = $a2x->toXml($data); //参数转xml
  39. try{
  40. $result = $client->getDiAnData($data); //请求获取接口
  41. }catch(\SoapFault $e){
  42. return $e->getMessage();
  43. }
  44. var_dump(htmlspecialchars($result));die;
  45. $obj = simplexml_load_string($result,"SimpleXMLElement", LIBXML_NOCDATA);
  46. $ins = json_encode($obj);
  47. $obj = json_decode($ins,true);
  48. var_dump($obj);die;
  49. }
  50. public function aa()
  51. {
  52. $conn = mysqli_connect('localhost','root','');
  53. $a = mysqli_select_db($conn,'tijianzhongxin');
  54. $sql = "select * from dianApiInfo where Barcode='12203020024872'";
  55. $result = mysqli_query($conn, $sql);
  56. $info = mysqli_fetch_row($result);
  57. if(!empty($info))
  58. {
  59. $return = [
  60. 'xml'=>$info[1],
  61. 'patientId'=>$info[2],
  62. 'barCode'=>$info[3]
  63. ];
  64. $a2x = new array2xml();
  65. $r = $a2x->toXml($return);
  66. return $r;
  67. }else{
  68. return '';
  69. }
  70. }
  71. }