|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73747 SoapClient::__getLastResponse() is empty if SoapFault raised
Submitted: 2016-12-15 09:43 UTC Modified: 2016-12-15 09:47 UTC
Avg. Score:4.5 ± 0.9
Reproduced:2 of 3 (66.7%)
Same Version:1 (50.0%)
Same OS:1 (50.0%)
From: richardh at channelgrabber dot com Assigned:
Status: Open Package: SOAP related
PHP Version: 7.1.0 OS: Ubuntu 14.04.1 LTS
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: richardh at channelgrabber dot com
New email:
PHP Version: OS:


 [2016-12-15 09:43 UTC] richardh at channelgrabber dot com
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 ( against a simple example wsdl (, by setting the response to always be a SoapFault.

Test script:
$soapClient = new SoapClient(
        'location' => '',
        'trace' => true,
        'exceptions' => true

try {
} 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:



Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-12-15 09:47 UTC] 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
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sat Sep 30 15:01:24 2023 UTC