Bug #73747 [Opn->Csd]: SoapClient::__getLastResponse() is empty if SoapFault raised

From: Date: Thu, 29 May 2025 17:53:34 +0000
Subject: Bug #73747 [Opn->Csd]: SoapClient::__getLastResponse() is empty if SoapFault raised
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-250183@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=73747&edit=1 ID: 73747 Updated by: nielsdos@php.net Reported by: richardh at channelgrabber dot com Summary: SoapClient::__getLastResponse() is empty if SoapFault raised -Status: Open +Status: Closed Type: Bug Package: SOAP related Operating System: Ubuntu 14.04.1 LTS PHP Version: 7.1.0 -Assigned To: +Assigned To: nielsdos Block user comment: N Private report: N New Comment: Thank you for your bug report. This issue has already been fixed in the latest released version of PHP, which you can download at http://www.php.net/downloads.php Was already fixed in 8.4. Previous Comments: ------------------------------------------------------------------------ [2016-12-15 09:47:43] richardh at channelgrabber dot com I couldn't post the actual expected result as the bug submitter was treating the soap request and response as spam, but for completeness please see this gist https://gist.github.com/RichardHeelin/47e701fdf0bc9a5d54de5d866f949280. ------------------------------------------------------------------------ [2016-12-15 09:43:12] richardh at channelgrabber dot com Description: ------------ If you configure a SoapClient with both exceptions and trace set to TRUE, and the server errors with a SoapFault, the client throws a php SoapFault exception. In php 5.6, if the SoapFault was caught, you could ask the SoapClient for the request SoapClient::__getLastRequest() and response SoapClient::__getLastResponse() to investigate the issue. However with php 7.1, and 7.0 it seems, both methods return an empty string if a SoapFault was thrown. Expected behaviour is the return of the failed request and response so you can investigate the issue. We have been able to reproduce the issues by testing against a mock server created with SoapUI (https://www.soapui.org/downloads/soapui.html) against a simple example wsdl (https://www.tutorialspoint.com/wsdl/wsdl_example.htm), by setting the response to always be a SoapFault. Test script: --------------- <?php $soapClient = new SoapClient( './HelloService.wsdl', [ 'location' => 'http://127.0.0.1:8080', 'trace' => true, 'exceptions' => true ] ); try { $soapClient->sayHello('Php'); } catch (SoapFault $exception) { echo 'Request: ' . trim($soapClient->__getLastRequest()) . PHP_EOL; echo PHP_EOL; echo 'Response: ' . trim($soapClient->__getLastResponse()) . PHP_EOL; } Expected result: ---------------- Request: <XML REQUEST> Response: <XML RESPONSE> Actual result: -------------- Request: Response: ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=73747&edit=1

« previous php.bugs (#250183) next »