I created the following helper function:
function mainSoap(){
return new SoapClient('https://soap.url',[
'stream_context' => stream_context_create([
'ssl' => [
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
]
]);
]);
}
and I'm using it like $result=mainSoap()->GetSometing($parameters);
Everything works fine, but in terms of performance, I would like to know if is better to close the soap connection or not.
UPDATE
I created another function in order to close the connection after getting the response, but I still could't find a close method for SoapClient.
function mainSoap(string $call=null, array $vars=[]){
$url="https://soap.url";
$wsdl=new SoapClient($url,[
'trace' => false,
'keep_alive' => false,
'stream_context' => stream_context_create([
'ssl' => [
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
]
]),
'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | SOAP_COMPRESSION_DEFLATE
]);
$response=$wsdl->__soapCall($call,$vars);
//Looking for something like $wsdl->close();
return $response;
}
and I'm using it like $result=mainSoap('GetSometing',[$parameters]);
from PHP: Is it better to close SoapClient connection?
No comments:
Post a Comment