香洲二院小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mini_xzey/app/Utils/Transfer/HisSoapClient/ClientSoapTransfer.php

79 lines
2.0 KiB

<?php
declare(strict_types=1);
namespace App\Utils\Transfer\HisSoapClient;
use App\Utils\Transfer\SoapTransferAbstract;
use Exception;
use WsdlToPhp\PackageBase\SoapClientInterface;
class ClientSoapTransfer extends SoapTransferAbstract
{
/**
* MediWayTransfer Construct
* @param string $his_name
*/
public function __construct(string $his_name = "")
{
parent::__construct($his_name);
}
/**
* 初始化
*/
public function initialize(): void
{
parent::initialize();
}
/**
* 设置客户端选项
* @return array
*/
public function clientOption(): array
{
return [
SoapClientInterface::WSDL_URL => config('hisservice.his_soap.url'),
SoapClientInterface::WSDL_LOCATION => config('hisservice.his_soap.location'),
SoapClientInterface::WSDL_CONNECTION_TIMEOUT => 180,
SoapClientInterface::WSDL_TRACE => 1,
SoapClientInterface::WSDL_EXCEPTIONS => true,
SoapClientInterface::WSDL_STREAM_CONTEXT => stream_context_create([
'ssl' => [
// 'cafile' => base_path('cert/cacert-2024-03-11.pem'),
'verify_peer' => false,
'verify_peer_name' => false
],
])
];
}
/**
* 响应格式化
* @param mixed $data
* @return mixed
* @throws Exception
*/
public function responseFormat(mixed $data): mixed
{
try {
// 此处为xml格式
$obj = simplexml_load_string((string)$data, 'SimpleXMLElement', LIBXML_NOCDATA);
return json_decode((string)json_encode($obj), true);
} catch (Exception $e) {
throw new Exception($e->getMessage());
}
}
/**
* 返回值字段
* @return string
*/
public function transferResponseStr(): string
{
return $this->transfer_name. 'Result';
}
}