SoapFaultWithTracingData now provides request / response information from Server SoapFaults

This commit is contained in:
Petr Bechyně
2017-05-30 18:29:51 +02:00
parent 8db9b374e4
commit d495f22413
4 changed files with 262 additions and 59 deletions

View File

@ -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) {