Index.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. $client = new \SoapClient("http://112.103.134.89:10020/server.php?wsdl");
  35. // $client = new \SoapClient('http://localhost:8085/server.php?wsdl');
  36. // use_soap_error_handler(false);
  37. // $requestUrl = "localhost:8085/server.php?wsdl";
  38. // $options = array("trace" => 1, "cache_wsdl" => WSDL_CACHE_NONE,"exception" => 0,'location'=>'localhost:8085/server.php?wsdl','uri'=>'http://tempuri.org/');
  39. // $client = new \SoapClient($requestUrl, $options);
  40. $data = [
  41. 'Barcode'=>'12203310010001'
  42. ]; //请求参数
  43. $a2x = new array2xml();
  44. $data = $a2x->toXml($data); //参数转xml
  45. try{
  46. $result = $client->getDiAnData($data); //请求获取接口
  47. }catch(\SoapFault $e){
  48. return $e->getMessage();
  49. }
  50. var_dump(htmlspecialchars($result));die;
  51. $obj = simplexml_load_string($result,"SimpleXMLElement", LIBXML_NOCDATA);
  52. $ins = json_encode($obj);
  53. $obj = json_decode($ins,true);
  54. var_dump($obj);die;
  55. }
  56. public function aa()
  57. {
  58. $conn = mysqli_connect('localhost','root','');
  59. $a = mysqli_select_db($conn,'tijianzhongxin');
  60. $sql = "select * from dianApiInfo where Barcode='12203020024872'";
  61. $result = mysqli_query($conn, $sql);
  62. $info = mysqli_fetch_row($result);
  63. if(!empty($info))
  64. {
  65. $return = [
  66. 'xml'=>$info[1],
  67. 'patientId'=>$info[2],
  68. 'barCode'=>$info[3]
  69. ];
  70. $a2x = new array2xml();
  71. $r = $a2x->toXml($return);
  72. return $r;
  73. }else{
  74. return '';
  75. }
  76. }
  77. }