SoapFaultWithTracingData now provides request / response information from Server SoapFaults
This commit is contained in:
@ -92,7 +92,7 @@ class Curl
|
||||
curl_setopt($curlSession, CURLOPT_URL, $location);
|
||||
curl_setopt($curlSession, CURLOPT_HEADER, true);
|
||||
curl_setopt($curlSession, CURLOPT_RETURNTRANSFER, true);
|
||||
if (!is_null($request)) {
|
||||
if ($request !== null) {
|
||||
curl_setopt($curlSession, CURLOPT_POST, true);
|
||||
curl_setopt($curlSession, CURLOPT_POSTFIELDS, $request);
|
||||
} else {
|
||||
@ -162,25 +162,25 @@ class Curl
|
||||
if (!is_integer($httpResponseCode) || $httpResponseCode >= 400 || $httpResponseCode === 0) {
|
||||
|
||||
return new CurlResponse(
|
||||
$httpRequestHeadersAsString,
|
||||
$this->normalizeStringOrFalse($httpRequestHeadersAsString),
|
||||
$httpResponseCode,
|
||||
$httpResponseMessage,
|
||||
$httpResponseContentType,
|
||||
self::CURL_FAILED,
|
||||
$responseHeaders,
|
||||
$responseBody,
|
||||
$this->normalizeStringOrFalse($responseHeaders),
|
||||
$this->normalizeStringOrFalse($responseBody),
|
||||
$curlErrorMessage
|
||||
);
|
||||
}
|
||||
|
||||
return new CurlResponse(
|
||||
$httpRequestHeadersAsString,
|
||||
$this->normalizeStringOrFalse($httpRequestHeadersAsString),
|
||||
$httpResponseCode,
|
||||
$httpResponseMessage,
|
||||
$httpResponseContentType,
|
||||
self::CURL_SUCCESS,
|
||||
$responseHeaders,
|
||||
$responseBody
|
||||
$this->normalizeStringOrFalse($responseHeaders),
|
||||
$this->normalizeStringOrFalse($responseBody)
|
||||
);
|
||||
}
|
||||
|
||||
@ -235,4 +235,13 @@ class Curl
|
||||
|
||||
throw new Exception('Cannot parse WSDL url redirect: ' . $url);
|
||||
}
|
||||
|
||||
private function normalizeStringOrFalse($string)
|
||||
{
|
||||
if ($string === false || $string === '') {
|
||||
$string = null;
|
||||
}
|
||||
|
||||
return $string;
|
||||
}
|
||||
}
|
||||
|
@ -316,26 +316,31 @@ class SoapClient extends \SoapClient
|
||||
{
|
||||
$soapResponse = $this->getSoapResponseFromStorage();
|
||||
if ($soapResponse instanceof SoapResponse) {
|
||||
$tracingData = new SoapResponseTracingData(
|
||||
'Content-Type: ' . $soapResponse->getRequest()->getContentType(),
|
||||
$soapResponse->getRequest()->getContent(),
|
||||
'Content-Type: ' . $soapResponse->getContentType(),
|
||||
$soapResponse->getResponseContent()
|
||||
);
|
||||
$soapFault = $this->throwSoapFaultByTracing(
|
||||
SoapFaultPrefixEnum::PREFIX_PHP . '-' . $nativePhpSoapFault->getCode(),
|
||||
$nativePhpSoapFault->getMessage(),
|
||||
$tracingData
|
||||
$this->getSoapResponseTracingDataFromNativeSoapFault(
|
||||
$nativePhpSoapFault,
|
||||
new SoapResponseTracingData(
|
||||
'Content-Type: '.$soapResponse->getRequest()->getContentType(),
|
||||
$soapResponse->getRequest()->getContent(),
|
||||
'Content-Type: '.$soapResponse->getContentType(),
|
||||
$soapResponse->getResponseContent()
|
||||
)
|
||||
)
|
||||
);
|
||||
} else {
|
||||
$soapFault = $this->throwSoapFaultByTracing(
|
||||
$nativePhpSoapFault->faultcode,
|
||||
$nativePhpSoapFault->getMessage(),
|
||||
new SoapResponseTracingData(
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null
|
||||
$this->getSoapResponseTracingDataFromNativeSoapFault(
|
||||
$nativePhpSoapFault,
|
||||
new SoapResponseTracingData(
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
@ -343,6 +348,18 @@ class SoapClient extends \SoapClient
|
||||
return $soapFault;
|
||||
}
|
||||
|
||||
private function getSoapResponseTracingDataFromNativeSoapFault(
|
||||
SoapFault $nativePhpSoapFault,
|
||||
SoapResponseTracingData $defaultSoapFaultTracingData
|
||||
) {
|
||||
if ($nativePhpSoapFault instanceof SoapFaultWithTracingData) {
|
||||
|
||||
return $nativePhpSoapFault->getSoapResponseTracingData();
|
||||
}
|
||||
|
||||
return $defaultSoapFaultTracingData;
|
||||
}
|
||||
|
||||
private function getHttpHeadersBySoapVersion(SoapRequest $soapRequest)
|
||||
{
|
||||
if ($soapRequest->getVersion() === SOAP_1_1) {
|
||||
|
Reference in New Issue
Block a user