Index.php 2.1 KB

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