Index.php 2.5 KB

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