<?php
namespace Engine\Soap; class SoapClientCurl extends SoapClient { protected function iniSet() { ini_set("soap.wsdl_cache_enabled", 1); ini_set("soap.wsdl_cache", WSDL_CACHE_DISK); } public function __doRequest(string $request, string $location, string $action, int $version, bool $one_way = FALSE) :?string { $curl = curl_init ( $location ); curl_setopt($curl, CURLOPT_VERBOSE, FALSE); curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($curl, CURLOPT_POST, TRUE); curl_setopt($curl, CURLOPT_POSTFIELDS, $request); curl_setopt($curl, CURLOPT_HEADER, FALSE); $HTTPheaders = []; $HTTPheaders[] = "Content-Type: text/xml"; foreach ($this->options->HTTPHeaders as $HTTPheader) { $HTTPheaders[] = sprintf("%s: %s", $HTTPheader['key'], str_replace("\n", "", $HTTPheader['value'])); } curl_setopt($curl, CURLOPT_HTTPHEADER, $HTTPheaders); if ($this->options->socket_timeout) { curl_setopt($curl, CURLOPT_TIMEOUT, $this->options->socket_timeout); } if ($this->options->connection_timeout) { curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, $this->options->connection_timeout); } $response = curl_exec($curl); if (curl_errno( $curl )) { throw new \SoapFault(sprintf("CURL error %d", curl_errno($curl)), curl_error($curl)); } if (! $one_way) { return ($response); } return null; } } 