|
|
|
@ -41,6 +41,10 @@ class SoapClient extends \SoapClient
|
|
|
|
|
protected $soapClientOptions;
|
|
|
|
|
protected $soapOptions;
|
|
|
|
|
private $curl;
|
|
|
|
|
/** @var SoapAttachment[] */
|
|
|
|
|
private $soapAttachmentsOnRequestStorage;
|
|
|
|
|
/** @var SoapResponse */
|
|
|
|
|
private $soapResponseStorage;
|
|
|
|
|
|
|
|
|
|
public function __construct(SoapClientOptions $soapClientOptions, SoapOptions $soapOptions)
|
|
|
|
|
{
|
|
|
|
@ -51,20 +55,20 @@ class SoapClient extends \SoapClient
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
@parent::__construct(
|
|
|
|
|
$this->loadWsdl(
|
|
|
|
|
$wsdlPath = $this->loadWsdl(
|
|
|
|
|
$this->curl,
|
|
|
|
|
$soapOptions->getWsdlFile(),
|
|
|
|
|
$soapOptions->getWsdlCacheType()
|
|
|
|
|
),
|
|
|
|
|
$soapClientOptions->toArray() + $soapOptions->toArray()
|
|
|
|
|
$soapOptions->getWsdlCacheType(),
|
|
|
|
|
false
|
|
|
|
|
);
|
|
|
|
|
} catch (Exception $e) {
|
|
|
|
|
throw new SoapFault(
|
|
|
|
|
SoapFaultEnum::SOAP_FAULT_SOAP_CLIENT_ERROR,
|
|
|
|
|
'Could not create SoapClient instance with message: '.$e->getMessage()
|
|
|
|
|
'Unable to load WsdlPath ('.$soapOptions->getWsdlFile().') with message: '.$e->getMessage().' in file: '.$e->getFile().' (line: '.$e->getLine().')'
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@parent::__construct($wsdlPath, $soapClientOptions->toArray() + $soapOptions->toArray());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -82,16 +86,16 @@ class SoapClient extends \SoapClient
|
|
|
|
|
/**
|
|
|
|
|
* Using __soapCall returns only response string, use soapCall instead.
|
|
|
|
|
*
|
|
|
|
|
* @param string $functionName
|
|
|
|
|
* @param string $function_name
|
|
|
|
|
* @param array $arguments
|
|
|
|
|
* @param array|null $options
|
|
|
|
|
* @param null $inputHeaders
|
|
|
|
|
* @param array|null $outputHeaders
|
|
|
|
|
* @param null $input_headers
|
|
|
|
|
* @param array|null $output_headers
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
|
|
|
|
public function __soapCall($functionName, $arguments, $options = null, $inputHeaders = null, &$outputHeaders = null)
|
|
|
|
|
public function __soapCall($function_name, $arguments, $options = null, $input_headers = null, &$output_headers = null)
|
|
|
|
|
{
|
|
|
|
|
return $this->soapCall($functionName, $arguments, $options, $inputHeaders, $outputHeaders)->getContent();
|
|
|
|
|
return $this->soapCall($function_name, $arguments, $options, $input_headers, $output_headers)->getResponseContent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -105,17 +109,13 @@ class SoapClient extends \SoapClient
|
|
|
|
|
*/
|
|
|
|
|
public function soapCall($functionName, array $arguments, array $soapAttachments = [], array $options = null, $inputHeaders = null, array &$outputHeaders = null)
|
|
|
|
|
{
|
|
|
|
|
ob_start();
|
|
|
|
|
parent::__soapCall($functionName, $arguments, $options, $inputHeaders, $outputHeaders);
|
|
|
|
|
$nativeSoapClientRequest = $this->mapNativeDataJsonToDto(ob_get_clean());
|
|
|
|
|
$this->setSoapAttachmentsOnRequestToStorage($soapAttachments);
|
|
|
|
|
$soapResponseAsObject = parent::__soapCall($functionName, $arguments, $options, $inputHeaders, $outputHeaders);
|
|
|
|
|
|
|
|
|
|
return $this->performSoapRequest(
|
|
|
|
|
$nativeSoapClientRequest->request,
|
|
|
|
|
$nativeSoapClientRequest->location,
|
|
|
|
|
$nativeSoapClientRequest->action,
|
|
|
|
|
$nativeSoapClientRequest->version,
|
|
|
|
|
$soapAttachments
|
|
|
|
|
);
|
|
|
|
|
$soapResponse = $this->getSoapResponseFromStorage();
|
|
|
|
|
$soapResponse->setResponseObject($soapResponseAsObject);
|
|
|
|
|
|
|
|
|
|
return $soapResponse;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -131,34 +131,16 @@ class SoapClient extends \SoapClient
|
|
|
|
|
*/
|
|
|
|
|
public function __doRequest($request, $location, $action, $version, $oneWay = 0)
|
|
|
|
|
{
|
|
|
|
|
$soapClientNativeDataTransferObject = new SoapClientNativeDataTransferObject(
|
|
|
|
|
$soapResponse = $this->performSoapRequest(
|
|
|
|
|
$request,
|
|
|
|
|
$location,
|
|
|
|
|
$action,
|
|
|
|
|
$version
|
|
|
|
|
$version,
|
|
|
|
|
$this->getSoapAttachmentsOnRequestFromStorage()
|
|
|
|
|
);
|
|
|
|
|
echo json_encode($soapClientNativeDataTransferObject);
|
|
|
|
|
$this->setSoapResponseToStorage($soapResponse);
|
|
|
|
|
|
|
|
|
|
return $request;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Custom request method to be able to modify the SOAP messages.
|
|
|
|
|
* $oneWay parameter is not used at the moment.
|
|
|
|
|
*
|
|
|
|
|
* @param mixed $request Request object
|
|
|
|
|
* @param string $location Location
|
|
|
|
|
* @param string $action SOAP action
|
|
|
|
|
* @param int $version SOAP version
|
|
|
|
|
* @param SoapAttachment[] $soapAttachments SOAP attachments array
|
|
|
|
|
*
|
|
|
|
|
* @return SoapResponse
|
|
|
|
|
*/
|
|
|
|
|
public function performSoapRequest($request, $location, $action, $version, array $soapAttachments = [])
|
|
|
|
|
{
|
|
|
|
|
$soapRequest = $this->createSoapRequest($location, $action, $version, $request, $soapAttachments);
|
|
|
|
|
|
|
|
|
|
return $this->performHttpSoapRequest($soapRequest);
|
|
|
|
|
return $soapResponse->getResponseContent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** @deprecated */
|
|
|
|
@ -201,6 +183,25 @@ class SoapClient extends \SoapClient
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Custom request method to be able to modify the SOAP messages.
|
|
|
|
|
* $oneWay parameter is not used at the moment.
|
|
|
|
|
*
|
|
|
|
|
* @param mixed $request Request object
|
|
|
|
|
* @param string $location Location
|
|
|
|
|
* @param string $action SOAP action
|
|
|
|
|
* @param int $version SOAP version
|
|
|
|
|
* @param SoapAttachment[] $soapAttachments SOAP attachments array
|
|
|
|
|
*
|
|
|
|
|
* @return SoapResponse
|
|
|
|
|
*/
|
|
|
|
|
private function performSoapRequest($request, $location, $action, $version, array $soapAttachments = [])
|
|
|
|
|
{
|
|
|
|
|
$soapRequest = $this->createSoapRequest($location, $action, $version, $request, $soapAttachments);
|
|
|
|
|
|
|
|
|
|
return $this->performHttpSoapRequest($soapRequest);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param string $location Location
|
|
|
|
|
* @param string $action SOAP action
|
|
|
|
@ -311,14 +312,13 @@ class SoapClient extends \SoapClient
|
|
|
|
|
*/
|
|
|
|
|
private function loadWsdl(Curl $curl, $wsdlPath, $wsdlCacheType, $resolveRemoteIncludes = true)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
$wsdlDownloader = new WsdlDownloader($curl);
|
|
|
|
|
$wsdlDownloader = new WsdlDownloader();
|
|
|
|
|
try {
|
|
|
|
|
$loadedWsdlFilePath = $wsdlDownloader->getWsdlPath($curl, $wsdlPath, $wsdlCacheType, $resolveRemoteIncludes);
|
|
|
|
|
} catch (Exception $e) {
|
|
|
|
|
throw new SoapFault(
|
|
|
|
|
SoapFaultEnum::SOAP_FAULT_WSDL,
|
|
|
|
|
'Unable to load WsdlPath: ' . $e->getMessage()
|
|
|
|
|
'Unable to load WsdlPath ('.$wsdlPath.') with message: '.$e->getMessage().' in file: '.$e->getFile().' (line: '.$e->getLine().')'
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -338,18 +338,6 @@ class SoapClient extends \SoapClient
|
|
|
|
|
return $filters;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function mapNativeDataJsonToDto($nativeDataJson)
|
|
|
|
|
{
|
|
|
|
|
$nativeData = json_decode($nativeDataJson);
|
|
|
|
|
|
|
|
|
|
return new SoapClientNativeDataTransferObject(
|
|
|
|
|
$nativeData->request,
|
|
|
|
|
$nativeData->location,
|
|
|
|
|
$nativeData->action,
|
|
|
|
|
$nativeData->version
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function returnSoapResponseByTracing(
|
|
|
|
|
$isTracingEnabled,
|
|
|
|
|
SoapRequest $soapRequest,
|
|
|
|
@ -407,4 +395,33 @@ class SoapClient extends \SoapClient
|
|
|
|
|
throw new Exception('SoapClientOptions tracing disabled, turn on trace attribute');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function setSoapResponseToStorage(SoapResponse $soapResponseStorage)
|
|
|
|
|
{
|
|
|
|
|
$this->soapResponseStorage = $soapResponseStorage;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param SoapAttachment[] $soapAttachments
|
|
|
|
|
*/
|
|
|
|
|
private function setSoapAttachmentsOnRequestToStorage(array $soapAttachments)
|
|
|
|
|
{
|
|
|
|
|
$this->soapAttachmentsOnRequestStorage = $soapAttachments;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function getSoapAttachmentsOnRequestFromStorage()
|
|
|
|
|
{
|
|
|
|
|
$soapAttachmentsOnRequest = $this->soapAttachmentsOnRequestStorage;
|
|
|
|
|
$this->soapAttachmentsOnRequestStorage = null;
|
|
|
|
|
|
|
|
|
|
return $soapAttachmentsOnRequest;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function getSoapResponseFromStorage()
|
|
|
|
|
{
|
|
|
|
|
$soapResponse = $this->soapResponseStorage;
|
|
|
|
|
$this->soapResponseStorage = null;
|
|
|
|
|
|
|
|
|
|
return $soapResponse;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|